Skip to content

Commit

Permalink
Allow passing in null value to CalendarDay field (#3245)
Browse files Browse the repository at this point in the history
* Allow passing in `null` value to CalendarDay field

* Update .changeset/lucky-buckets-carry.md

Co-authored-by: Aman Singh <aman.singh@thinkmill.com.au>
Co-authored-by: Mike <mike@madebymike.com.au>
  • Loading branch information
3 people authored Jul 9, 2020
1 parent 0cbb7e7 commit 4b95d8a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .changeset/lucky-buckets-carry.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 4 additions & 0 deletions packages/fields/src/types/CalendarDay/Implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand Down

0 comments on commit 4b95d8a

Please sign in to comment.