Skip to content

feat: reject non-calendar ISO strings#3061

Open
stelardn wants to merge 1 commit intohapijs:masterfrom
stelardn:feat/strict-iso-date-validation
Open

feat: reject non-calendar ISO strings#3061
stelardn wants to merge 1 commit intohapijs:masterfrom
stelardn:feat/strict-iso-date-validation

Conversation

@stelardn
Copy link
Copy Markdown

Fixes #2733

This adds a stricter validation to string().isoDate(), rejecting dates that do not exist in the calendar.

It does so by:

  • Validating that the day component of the ISO string matches the day derived from the corresponding JavaScript Date.
  • Handling edge cases where the difference between days is caused by T24:00 notation, in order to keep support for valid T24:00 ISO strings.
  • Preventing invalid dates such as April 31st from being accepted, even when combined with T24:00.

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.

Joi.string().isoDate() accepts iso strings that have invalid values, but have valid iso string formats

1 participant