Currently here (for invalid data to parse_obj) and here (in parse_raw) we use '__obj__' as the location for errors to indicate an error which is general to the model, not specific to a field.
We should change this in v1 to __root__ to better match other nomenclature, eg. custom root types, where we use __root__.
We should also implement at some point entire model validation, as discussed at #691 (comment). I guess to match the above naming, we should do this using a special value to a validator @validator('__root__'). If this raised an error it would end up in ValidationError details with 'location': '__root__', (Unless it's a "@validator('__root__')" validator for a submodel, when obviously it should have the location of that model.
Perhaps it would would be nice to have a special decorator @root_validator which is an alias of @validator('__root__'), we should support multiple root validators either as a result of inheritance or on a single class.
I guess the __obj__ > __root__ change must happen with v1 and the new root validator could go in a later release, but we should be sure we won't need other backwards incompatible changes to implement the root validator.
Thoughts?
Currently here (for invalid data to
parse_obj) and here (inparse_raw) we use'__obj__'as the location for errors to indicate an error which is general to the model, not specific to a field.We should change this in v1 to
__root__to better match other nomenclature, eg. custom root types, where we use__root__.We should also implement at some point entire model validation, as discussed at #691 (comment). I guess to match the above naming, we should do this using a special value to a validator
@validator('__root__'). If this raised an error it would end up inValidationErrordetails with'location': '__root__', (Unless it's a "@validator('__root__')" validator for a submodel, when obviously it should have the location of that model.Perhaps it would would be nice to have a special decorator
@root_validatorwhich is an alias of@validator('__root__'), we should support multiple root validators either as a result of inheritance or on a single class.I guess the
__obj__>__root__change must happen with v1 and the new root validator could go in a later release, but we should be sure we won't need other backwards incompatible changes to implement the root validator.Thoughts?