pip_services3_commons.validate.OrRule module

pip_services3_commons.validate.OrRule

Or rule implementation

copyright

Conceptual Vision Consulting LLC 2018-2019, see AUTHORS for more details.

license

MIT, see LICENSE for more details.

class pip_services3_commons.validate.OrRule.OrRule(*rules: pip_services3_commons.validate.IValidationRule.IValidationRule)

Bases: pip_services3_commons.validate.IValidationRule.IValidationRule

Validation rule to combine __rules with OR logical operation. When one of __rules returns no errors, than this rule also returns no errors. When all __rules return errors, than the rule returns all errors.

Example:

schema = Schema().with_rule(OrRule(ValueComparisonRule("LT", 1), ValueComparisonRule("GT", 10)))

schema.validate(0)          # Result: no error
schema.validate(5)          # Result: 5 must be less than 1 or 5 must be more than 10
schema.validate(20)         # Result: no error
validate(path: str, schema: <module 'pip_services3_commons.validate.Schema' from '/pip_services3_commons/validate/Schema.py'>, value: Any, results: List[pip_services3_commons.validate.ValidationResult.ValidationResult])

Validates a given args against this rule.

Parameters
  • path – a dot notation path to the args.

  • schema – a schema this rule is called from

  • value – a args to be validated.

  • results – a list with validation results to add new results.