1 | import { buildMessage, ValidateBy } from '../common/ValidateBy';
|
2 | export const IS_INT = 'isInt';
|
3 |
|
4 |
|
5 |
|
6 | export function isInt(val) {
|
7 | return typeof val === 'number' && Number.isInteger(val);
|
8 | }
|
9 |
|
10 |
|
11 |
|
12 | export function IsInt(validationOptions) {
|
13 | return ValidateBy({
|
14 | name: IS_INT,
|
15 | validator: {
|
16 | validate: (value, args) => isInt(value),
|
17 | defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be an integer number', validationOptions),
|
18 | },
|
19 | }, validationOptions);
|
20 | }
|
21 |
|
\ | No newline at end of file |