1 | import { buildMessage, ValidateBy } from '../common/ValidateBy';
|
2 | export const MIN = 'min';
|
3 |
|
4 |
|
5 |
|
6 | export function min(num, min) {
|
7 | return typeof num === 'number' && typeof min === 'number' && num >= min;
|
8 | }
|
9 |
|
10 |
|
11 |
|
12 | export function Min(minValue, validationOptions) {
|
13 | return ValidateBy({
|
14 | name: MIN,
|
15 | constraints: [minValue],
|
16 | validator: {
|
17 | validate: (value, args) => min(value, args.constraints[0]),
|
18 | defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must not be less than $constraint1', validationOptions),
|
19 | },
|
20 | }, validationOptions);
|
21 | }
|
22 |
|
\ | No newline at end of file |