File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 6363 return true
6464 }
6565
66+ function isValidDate ( value ) {
67+ // Check if the value is a string and can be converted to a Date object
68+ if ( typeof value === 'string' ) {
69+ const dateObject = new Date ( value ) ;
70+
71+ // Check if the result of the Date constructor is a valid Date object
72+ if ( ! isNaN ( dateObject ) && dateObject . toString ( ) !== 'Invalid Date' ) {
73+ return dateObject ; // It's a valid Date object
74+ }
75+ }
76+
77+ return value ; // It's not a valid Date object
78+ }
79+
6680 function dotNotationToObject ( data , obj = { } ) {
6781 try {
6882 for ( const key of Object . keys ( data ) ) {
69- let value = data [ key ]
83+ let value = isValidDate ( data [ key ] )
7084 let newObject = obj
7185 let oldObject = new Object ( obj )
7286 let keys = key . split ( '.' ) ;
616630 return {
617631 ObjectId,
618632 checkValue,
633+ isValidDate,
619634 dotNotationToObject,
620635 getValueFromObject,
621636 isObjectEmpty,
You can’t perform that action at this time.
0 commit comments