From Marshmallow#validation, I know I can register validators on specific fields in a Schema. If a validator fails, errors in :
data, errors = MySchema().load({"some":"data})
will include error information for any field which has failed validators :
errors
# => some error message for the field that failed
My question : Is it possible to validate at the Schema level (rather than at individual field level) and still return an error in the above way?
As an arbitrary example, say I wanted to validate that you tried to MySchema().load()
n distinct keys.
I currently have a @pre_load
method which checks the structure of the input and raise ValidationError('message')
if the data is ill-formed, but I would like to return it as result.errors like field validation does. What are my options?