Unexpected behavior. Do you have to explicitly specify format_checker? #946
-
Do you have to explicitly specify Expected: I would have expected that specifying Actual: There is no format_checker used by default. Setup:
First test (Unexpectedly, no errors):
Second test (Unexpectedly, no errors):
Third test (finally the error we're looking for):
Fourth test (circling back to our first test, we see this works too):
More information ... In the create validator function, we see jsonschema/jsonschema/validators.py Line 113 in fb85c66 jsonschema/jsonschema/validators.py Lines 154 to 160 in fb85c66 And then when jsonschema/jsonschema/validators.py Line 624 in fb85c66 But this contradicts what we see in the end, in the help text:
Later in the create validator function we see jsonschema/jsonschema/validators.py Line 190 in fb85c66 If, and I stress if, we wanted to instantiate a specific version of a validator, it appears that we can reference the FORMAT_CHECKER defined on that class.
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
As I mentioned in the issue, yes, you need to specify a format checker because by default the specification says format should not do any asserting. You can do so either to |
Beta Was this translation helpful? Give feedback.
-
Hi, The sample I have creates a validator instance and hooks in the format_checker, but it doesn't appear to carry through. Full example:
The production code actually uses |
Beta Was this translation helpful? Give feedback.
As I mentioned in the issue, yes, you need to specify a format checker because by default the specification says format should not do any asserting. You can do so either to
jsonschema.validate
or toDraft202012Validator
if you repeatedly validate with the same schema.