Closed pohmelie closed 6 years ago
It looks like this can be achieved, by changing couple of places, where 'required'
checked to something like:
self.schema[field].get('required', self.forbid_known_missed)
Ok, I have successfully patched cerberus validator.py
with technic like above, tests are still ok and looks like added argument works fine. The only problem is since 'required'
became orphan there is an error here, but I hope this can be resolved.
if this gets added, i'd prefer the option name require_all
. some form of required
is needed in the name to clearly relate it to the required
rule.
should there also be a same-named flag for (sub-)schemas like allow_unknown
?
I think this would make for a nice addition. Feel free to submit a PR so, we can review it.
@pohmelie a feedback on the progress would be great to have rather soonish as we're getting closer to the next minor release after which new features can't be merged for a while due to planned, larger code changes.
There are four cases which I think should be covered with validator instance arguments:
allow_unknown=True
)Cerberus have
allow_unknown
option for validator, but have noallow_known_missed
/forbid_known_missed
or something like this. As stackoverflow question said, it is pretty annoying to setrequired: True
for all fields, cause they can be nested and schema looks noisy and dirty.