keleshev / schema

Schema validation just got Pythonic
MIT License
2.86k stars 214 forks source link

ignore_extra_keys is ignored if flavor == VALIDATOR #285

Open ukrsms opened 2 years ago

ukrsms commented 2 years ago

For a case when a validator like Or, And etc is used the ignore_extra_keys is taken as false and any extra fields cause a validation error For example: object {"str":"str", "extra":125} is valid for schema {"str":str} and ignore_extra_keys=true but it is not valid for schema Or({"str":str}, None) and ignore_extra_keys=true, however, it should be valid as well

Finally, I understood I needed to set it as Or({"str":str}, None, ignore_extra_keys=true), however, it is not evident enough, so it could be more convenient if Or to use ignore_extra_keys parameter from the Scheme object

elavaud commented 1 year ago

I have been banging my head for a few hours because of this.

ignore_extra_keys, although given to Schema, is not passed to the Or and And described in it. So or: