Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2.21.0 fails to validate YYYY-10-DD date format #190

Closed
oalsaab opened this issue Nov 29, 2024 · 1 comment
Closed

Version 2.21.0 fails to validate YYYY-10-DD date format #190

oalsaab opened this issue Nov 29, 2024 · 1 comment
Labels

Comments

@oalsaab
Copy link

oalsaab commented Nov 29, 2024

When trying to compile or validate a valid ISO 8601 date in the month of October, fastjsonschema returns a JsonSchemaValueException.

>>> fastjsonschema.compile({'$schema': 'http://json-schema.org/draft-07/schema', 'format': 'date'})('2018-10-05')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 6, in validate
fastjsonschema.exceptions.JsonSchemaValueException: data must be date

The issue was most likely caused here:

'date': r'^(?P<year>\d{4})-(?P<month>(0[1-9]|1[1-2]))-(?P<day>(0[1-9]|[12]\d|3[01]))\Z',

To match October correctly it should probably be (?P<month>(0[1-9]|1[0-2])) for the month regex part.

@horejsek
Copy link
Owner

horejsek commented Dec 2, 2024

#191

@horejsek horejsek closed this as completed Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants