UNPKG

635 BJavaScriptView Raw
1import { buildMessage, ValidateBy } from '../common/ValidateBy';
2export const IS_INT = 'isInt';
3/**
4 * Checks if value is an integer.
5 */
6export function isInt(val) {
7 return typeof val === 'number' && Number.isInteger(val);
8}
9/**
10 * Checks if value is an integer.
11 */
12export 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//# sourceMappingURL=IsInt.js.map
\No newline at end of file