1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| import { buildMessage, ValidateBy } from '../common/ValidateBy';
| import isDivisibleByValidator from 'validator/lib/isDivisibleBy';
| export const IS_DIVISIBLE_BY = 'isDivisibleBy';
| /**
| * Checks if value is a number that's divisible by another.
| */
| export function isDivisibleBy(value, num) {
| return typeof value === 'number' && typeof num === 'number' && isDivisibleByValidator(String(value), num);
| }
| /**
| * Checks if value is a number that's divisible by another.
| */
| export function IsDivisibleBy(num, validationOptions) {
| return ValidateBy({
| name: IS_DIVISIBLE_BY,
| constraints: [num],
| validator: {
| validate: (value, args) => isDivisibleBy(value, args === null || args === void 0 ? void 0 : args.constraints[0]),
| defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be divisible by $constraint1', validationOptions),
| },
| }, validationOptions);
| }
| //# sourceMappingURL=IsDivisibleBy.js.map
|
|