UNPKG

829 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.IsInt = exports.isInt = exports.IS_INT = void 0;
4const ValidateBy_1 = require("../common/ValidateBy");
5exports.IS_INT = 'isInt';
6/**
7 * Checks if value is an integer.
8 */
9function isInt(val) {
10 return typeof val === 'number' && Number.isInteger(val);
11}
12exports.isInt = isInt;
13/**
14 * Checks if value is an integer.
15 */
16function IsInt(validationOptions) {
17 return (0, ValidateBy_1.ValidateBy)({
18 name: exports.IS_INT,
19 validator: {
20 validate: (value, args) => isInt(value),
21 defaultMessage: (0, ValidateBy_1.buildMessage)(eachPrefix => eachPrefix + '$property must be an integer number', validationOptions),
22 },
23 }, validationOptions);
24}
25exports.IsInt = IsInt;
26//# sourceMappingURL=IsInt.js.map
\No newline at end of file