Conditional requirement dependent on value of other fields in Cerberus
has been discussed many times. Usage of dependencies
doesn't meet the needs because fields can be unknown
when conditions are satisfied. Usage of oneof
was recommended but it may be too hard to work when several conditions and dependencies are met. What's the universal solution now?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
Quick Answer (TL;DR)
cerberus
package supports composite validation "out of the box".Detailed Answer
Context
Problem
Solution
validation-success
,validation-fail
, orvalidation-skipped
Example
Sample documents Sample validation rulesrule_vpath
name-value pair.Rationale
Pitfalls
rule_vpath
, which tells the system when to trigger specific rules, this adds a dependency on jmespath.See also