You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I followed the steps in the docs to populate default values. In my schema, I have a required declaration, with the implication being that defaults should be populated before it is evaluated.
When I set schema = {'required': ['foo'], 'properties': {'foo': {'default': 'bar'}}}, validation fails as required appears to be evaluated before the default is set.
If I change the order of declaration to be schema = {'properties': {'foo': {'default': 'bar'}}, 'required': ['foo']}, validation succeeds.
My schema is a JSON value that is being loaded in by json.loads, rather than a schema I define in Python.
Per the JSON docs, "An object is an unordered set of name/value pairs." I take this to mean that the behaviour should be the same regardless of the order of the key-value pairs.
Is there a way that we can avoid relying on required being defined after properties?
The text was updated successfully, but these errors were encountered:
I did search but apparently not thoroughly enough - this appears to be a duplicate of #742 - apologies!
I wonder if this should be documented as part of the linked FAQ? Feel free to close this issue, but I foresee issues where the consumer of the schema has no control over the schema itself, and I'm not sure how best to address that.
Maybe required could be "demoted" to the bottom of the processing list? But I guess that might still run into issues with other keywords
I followed the steps in the docs to populate default values. In my schema, I have a
required
declaration, with the implication being that defaults should be populated before it is evaluated.When I set
schema = {'required': ['foo'], 'properties': {'foo': {'default': 'bar'}}}
, validation fails asrequired
appears to be evaluated before the default is set.If I change the order of declaration to be
schema = {'properties': {'foo': {'default': 'bar'}}, 'required': ['foo']}
, validation succeeds.My schema is a JSON value that is being loaded in by
json.loads
, rather than a schema I define in Python.Per the JSON docs, "An object is an unordered set of name/value pairs." I take this to mean that the behaviour should be the same regardless of the order of the key-value pairs.
Is there a way that we can avoid relying on
required
being defined afterproperties
?The text was updated successfully, but these errors were encountered: