pip_services3_commons.validate.NotRule module

pip_services3_commons.validate.NotRule

Not 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.NotRule.NotRule(rule: pip_services3_commons.validate.IValidationRule.IValidationRule)

Bases: pip_services3_commons.validate.IValidationRule.IValidationRule

Validation rule negate another rule. When embedded rule returns no errors, than this rule return an error. When embedded rule return errors, than the rule returns no errors.

Example:

schema = Schema().with_rule(NotRule(ValueComparisonRule("EQ", 1)))

schema.validate(1)          # Result: error
schema.validate(5)          # 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.