Skip to content

Commit

Permalink
Fixes date widget crashing when no date format is mentioned (#322)
Browse files Browse the repository at this point in the history
Fixed by using a proper default format string for ISO dates
  • Loading branch information
hetunandu authored and mohanarpit committed Aug 17, 2020
1 parent 3b1c43d commit 78c4b5a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/client/src/constants/WidgetValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ export type Validator = (
props: WidgetProps,
dataTree?: DataTree,
) => ValidationResponse;

export const ISO_DATE_FORMAT = "YYYY-MM-DDTHH:mm:ss.SSSZ";
5 changes: 3 additions & 2 deletions app/client/src/utils/Validators.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import _ from "lodash";
import {
ISO_DATE_FORMAT,
VALIDATION_TYPES,
ValidationResponse,
ValidationType,
Expand Down Expand Up @@ -392,8 +393,8 @@ export const VALIDATORS: Record<ValidationType, Validator> = {
.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 {
Expand Down

0 comments on commit 78c4b5a

Please sign in to comment.