From 4b95d8a46d53d32b2873e350716311441cd37262 Mon Sep 17 00:00:00 2001 From: Amandeep Singh Date: Fri, 10 Jul 2020 07:36:44 +1000 Subject: [PATCH] Allow passing in `null` value to CalendarDay field (#3245) * Allow passing in `null` value to CalendarDay field * Update .changeset/lucky-buckets-carry.md Co-authored-by: Aman Singh Co-authored-by: Mike --- .changeset/lucky-buckets-carry.md | 8 ++++++++ packages/fields/src/types/CalendarDay/Implementation.js | 4 ++++ 2 files changed, 12 insertions(+) create mode 100644 .changeset/lucky-buckets-carry.md diff --git a/.changeset/lucky-buckets-carry.md b/.changeset/lucky-buckets-carry.md new file mode 100644 index 00000000000..9c079484297 --- /dev/null +++ b/.changeset/lucky-buckets-carry.md @@ -0,0 +1,8 @@ +--- +'@keystonejs/fields': patch +--- + +Allow passing in the `null` value to the **CalendarDay**[https://www.keystonejs.com/keystonejs/fields/src/types/calendar-day/#calendarday] field type. + +Passing in the `null` value for **CalendarDay** field was throwing a `TypeError` inside the inputValidation method of CalendarDay. +This fix allow passing the null value. diff --git a/packages/fields/src/types/CalendarDay/Implementation.js b/packages/fields/src/types/CalendarDay/Implementation.js index d24a3f1fed0..1b400eba142 100644 --- a/packages/fields/src/types/CalendarDay/Implementation.js +++ b/packages/fields/src/types/CalendarDay/Implementation.js @@ -64,6 +64,10 @@ export class CalendarDay extends Implementation { async validateInput({ resolvedData, addFieldValidationError }) { const initialValue = resolvedData[this.path]; + + // Allow passing in the `null` value to the CalendarDay field type + if (initialValue === null) return true; + const parsedValue = parseISO(resolvedData[this.path]); if (!(initialValue.length === 10 && isValid(parsedValue))) {