Closed rennat closed 13 years ago
hm.. i guess i'm not entirely sure what the intended behavior is (though a TypeError is definitely a bug)
it seems to me like specifying a format but passing in a None value should result in a failure, thoughts?
I expected that a schema that can be a string or null would only use the format attribute if it was not null. It was definitely an assumption on my part and may be wrong but It makes sense to me that there will be cases (I have one) when you have an optional date but the property should always be present.
The JSON Schema specification draft's section on the format attribute doesn't address this specifically.
...A format SHOULD only be used to give meaning to primitive types (string, integer, number, or boolean)...
What about when an object can be one of those primitive types or null?
This occurs when required=False on the field as well
The null
could be subjective but required=false
should definitely ignore format
(logically if not explicitly within the spec)
the format part of the spec is definitely lacking in detail, I found a few discussions elsewhere about this exact same ambiguity
I think that the solution is to validate that the input value is a string if a format that expects a string is applied, otherwise it is too ambiguous if format was checked or not
as far as required=False, that stems from an issue with validators not being checked in any particular order.. I think I can solve that one, if either of you have a decent solution I'd be happy to accept a patch though
assuming the solution in #6 is agreeable I'll be merging it in soon
fixed in latest commit
A type error is being raised when validating this property:
against this schema:
stack trace: