Closed JakeSummers closed 4 months ago
Supporting it via what mechanism?
Supporting it via what mechanism?
Any mechanism 😄 .
I would like to validate that the data inside my strings is correctly formatted as a date-time
.
I literally linked you to the docs to do so :)
Thanks, I see it now.
The solution is hidden in the See also
box here:
For anyone else running into the same issue, the fix is pretty simple:
@@ -3,6 +3,7 @@ import json
import pytest
from jsonschema import validate
from jsonschema.exceptions import ValidationError
+from jsonschema.validators import Draft202012Validator
@pytest.mark.parametrize(
@@ -79,4 +80,7 @@ def test_date_format():
""")
with pytest.raises(ValidationError):
- validate(example, schema)
+ validate(example,
+ schema,
+ format_checker=Draft202012Validator.FORMAT_CHECKER,
+ )
Link to doc on solution: https://python-jsonschema.readthedocs.io/en/stable/validate/#validating-formats
TLDR
String formatting isn't working. I have installed the
format
extras. :)Environment Info
Test Case
Returns: