pip_services3_commons.validate.AtLeastOneExistsRule module

pip_services3_commons.validate.AtLeastOneExistsRule

At least one exist 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.AtLeastOneExistsRule.AtLeastOneExistsRule(*properties: str)

Bases: pip_services3_commons.validate.IValidationRule.IValidationRule

Validation rule that check that at least one of the object properties is not None.

Example:

schema = Schema().with_rule(AtLeastOneExistsRule("field1", "field2"))
schema.validate({ 'field1': 1, 'field2': "A" })     # Result: no errors
schema.validate({ 'field1': 1 })                  # Result: no errors
schema.validate({ })                            # Result: at least one of properties field1, field2 must exist
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.