fix: Fix string gets converted to date causing validation error (#793)

This commit is contained in:
Tanmay Banage
2023-09-13 09:31:48 +05:30
committed by GitHub
parent 4f4e95fecb
commit ffef88731d

View File

@@ -97,7 +97,7 @@ export const getTodaysDateFormatted = (seperator: string) => {
export function convertDatesInObject(obj: any) {
for (let key in obj) {
if (typeof obj[key] === "string" && !isNaN(Date.parse(obj[key]))) {
if ((key === "createdAt" || key === "updatedAt") && !isNaN(Date.parse(obj[key]))) {
obj[key] = new Date(obj[key]);
} else if (typeof obj[key] === "object" && obj[key] !== null) {
convertDatesInObject(obj[key]);