UNPKG

785 BJavaScriptView Raw
1import { buildMessage, ValidateBy } from '../common/ValidateBy';
2export const MIN = 'min';
3/**
4 * Checks if the first number is greater than or equal to the second.
5 */
6export function min(num, min) {
7 return typeof num === 'number' && typeof min === 'number' && num >= min;
8}
9/**
10 * Checks if the first number is greater than or equal to the second.
11 */
12export 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//# sourceMappingURL=Min.js.map
\No newline at end of file