From 78c4b5a38287b4b97dac0fc08854282fd3e9217b Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Mon, 17 Aug 2020 10:33:15 +0530 Subject: [PATCH] Fixes date widget crashing when no date format is mentioned (#322) Fixed by using a proper default format string for ISO dates --- app/client/src/constants/WidgetValidation.ts | 2 ++ app/client/src/utils/Validators.ts | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/client/src/constants/WidgetValidation.ts b/app/client/src/constants/WidgetValidation.ts index 97416567141..556c0e6fe35 100644 --- a/app/client/src/constants/WidgetValidation.ts +++ b/app/client/src/constants/WidgetValidation.ts @@ -33,3 +33,5 @@ export type Validator = ( props: WidgetProps, dataTree?: DataTree, ) => ValidationResponse; + +export const ISO_DATE_FORMAT = "YYYY-MM-DDTHH:mm:ss.SSSZ"; diff --git a/app/client/src/utils/Validators.ts b/app/client/src/utils/Validators.ts index 449f23e8f11..7be2897b037 100644 --- a/app/client/src/utils/Validators.ts +++ b/app/client/src/utils/Validators.ts @@ -1,5 +1,6 @@ import _ from "lodash"; import { + ISO_DATE_FORMAT, VALIDATION_TYPES, ValidationResponse, ValidationType, @@ -392,8 +393,8 @@ export const VALIDATORS: Record = { .minute(0) .second(0) .millisecond(0); - const dateFormat = props.dateFormat ? props.dateFormat : moment.ISO_8601; - // const dateStr = moment().toISOString(); + const dateFormat = props.dateFormat ? props.dateFormat : ISO_DATE_FORMAT; + const todayDateString = today.format(dateFormat); if (dateString === undefined) { return {