Skip to content

fix dateTimeSchema NaN validation#283

Open
jshawl wants to merge 1 commit intoadamgibbons:masterfrom
jshawl:fix-silent-error
Open

fix dateTimeSchema NaN validation#283
jshawl wants to merge 1 commit intoadamgibbons:masterfrom
jshawl:fix-silent-error

Conversation

@jshawl
Copy link

@jshawl jshawl commented Oct 20, 2024

This PR fixes an issue where the dateTimeSchema silently errors on NaN values in the start array:

const {error, value} = ics.createEvent({
  start: [NaN, 12, 1]
})
// error === {}
// value === null

This is because:

[1, 2, NaN, 4].indexOf(NaN) === -1

which then throws a TypeError in yup:

TypeError: lazy() functions must return a valid schema

but it was being caught here

return {error: Object.assign({}, error), value: undefined}

@jshawl jshawl changed the title fix dateTimeSchema NaN validation fix dateTimeSchema NaN validation Oct 20, 2024
@jshawl jshawl marked this pull request as ready for review October 20, 2024 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant