We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e4ace79 commit aaf9914Copy full SHA for aaf9914
packages/operators/src/json/reviver.js
@@ -20,9 +20,15 @@ const isValidUrl = value =>
20
isString(value) && URL.canParse(value) && /^[\w]+:\/\/\S+$/gm.test(value);
21
22
const isValidISODateString = value => {
23
- if (!isString(value) || !/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/.test(value)) return false;
24
- const d = new Date(value);
25
- return d instanceof Date && !isNaN(d.getTime()) && d.toISOString() === value; // valid date
+ if (typeof value !== 'string' || value.trim() === '') {
+ return false;
+ }
26
+ try {
27
+ const d = new Date(value);
28
+ return !Number.isNaN(d.valueOf()) && d.toISOString() === value;
29
+ } catch {
30
31
32
};
33
34
const isString = value => value?.constructor === String;
0 commit comments