pip_services3_commons.validate.ValueComparisonRule module

pip_services3_commons.validate.ValueComparisonRule

Value comparison 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.ValueComparisonRule.ValueComparisonRule(operation: Any, value: Any)

Bases: pip_services3_commons.validate.IValidationRule.IValidationRule

Validation rule that compares args to a constant.

Example:

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

schema.validate(1)          # Result: no errors
schema.validate(2)          # Result: 2 is not equal to 1
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.