1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | exports.IsISO8601 = exports.isISO8601 = exports.IS_ISO8601 = void 0;
|
7 | const ValidateBy_1 = require("../common/ValidateBy");
|
8 | const isISO8601_1 = __importDefault(require("validator/lib/isISO8601"));
|
9 | exports.IS_ISO8601 = 'isIso8601';
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | function isISO8601(value, options) {
|
16 | return typeof value === 'string' && (0, isISO8601_1.default)(value, options);
|
17 | }
|
18 | exports.isISO8601 = isISO8601;
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | function IsISO8601(options, validationOptions) {
|
25 | return (0, ValidateBy_1.ValidateBy)({
|
26 | name: exports.IS_ISO8601,
|
27 | constraints: [options],
|
28 | validator: {
|
29 | validate: (value, args) => isISO8601(value, args.constraints[0]),
|
30 | defaultMessage: (0, ValidateBy_1.buildMessage)(eachPrefix => eachPrefix + '$property must be a valid ISO 8601 date string', validationOptions),
|
31 | },
|
32 | }, validationOptions);
|
33 | }
|
34 | exports.IsISO8601 = IsISO8601;
|
35 |
|
\ | No newline at end of file |