Fixes date widget crashing when no date format is mentioned (#322)

Fixed by using a proper default format string for ISO dates
This commit is contained in:
Hetu Nandu 2020-08-17 10:33:15 +05:30 committed by GitHub
parent cbc4796921
commit 855fc1c00a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -33,3 +33,5 @@ export type Validator = (
props: WidgetProps,
dataTree?: DataTree,
) => ValidationResponse;
export const ISO_DATE_FORMAT = "YYYY-MM-DDTHH:mm:ss.SSSZ";

View File

@ -1,5 +1,6 @@
import _ from "lodash";
import {
ISO_DATE_FORMAT,
VALIDATION_TYPES,
ValidationResponse,
ValidationType,
@ -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 {