pip_services3_commons.validate.PropertiesComparisonRule module

pip_services3_commons.validate.PropertiesComparisonRule

Properties 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.PropertiesComparisonRule.PropertiesComparisonRule(property1: str, operation: str, property2: str)

Bases: pip_services3_commons.validate.IValidationRule.IValidationRule

Validation rule that compares two object properties.

Example:

schema = ObjectSchema().with_rule(PropertyComparisonRule("field1", "NE", "field2"))

schema.validate({ field1: 1, field2: 2 })       # Result: no errors
schema.validate({ field1: 1, field2: 1 })       # Result: field1 shall not be equal to field2
schema.validate({})                             # Result: no errors
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.