1 | import { buildMessage, ValidateBy } from '../common/ValidateBy';
|
2 | import { isISO8601 } from './IsISO8601';
|
3 | export const IS_DATE_STRING = 'isDateString';
|
4 |
|
5 |
|
6 |
|
7 | export function isDateString(value, options) {
|
8 | return isISO8601(value, options);
|
9 | }
|
10 |
|
11 |
|
12 |
|
13 | export function IsDateString(options, validationOptions) {
|
14 | return ValidateBy({
|
15 | name: IS_DATE_STRING,
|
16 | constraints: [options],
|
17 | validator: {
|
18 | validate: (value, args) => isDateString(value),
|
19 | defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be a valid ISO 8601 date string', validationOptions),
|
20 | },
|
21 | }, validationOptions);
|
22 | }
|
23 |
|
\ | No newline at end of file |