File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
packages/operators/src/json Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -20,9 +20,15 @@ const isValidUrl = value =>
20
20
isString ( value ) && URL . canParse ( value ) && / ^ [ \w ] + : \/ \/ \S + $ / gm. test ( value ) ;
21
21
22
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
23
+ if ( typeof value !== 'string' || value . trim ( ) === '' ) {
24
+ return false ;
25
+ }
26
+ try {
27
+ const d = new Date ( value ) ;
28
+ return ! Number . isNaN ( d . valueOf ( ) ) && d . toISOString ( ) === value ;
29
+ } catch {
30
+ return false ;
31
+ }
26
32
} ;
27
33
28
34
const isString = value => value ?. constructor === String ;
You can’t perform that action at this time.
0 commit comments