Pip-Services-Commons-Dotnet
Public Member Functions | Private Attributes | List of all members
PipServices3.Commons.Validate.OrRule Class Reference

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. More...

Inheritance diagram for PipServices3.Commons.Validate.OrRule:
PipServices3.Commons.Validate.IValidationRule

Public Member Functions

 OrRule (params IValidationRule[] rules)
 Creates a new validation rule and sets its values. More...
 
void Validate (string path, Schema schema, object value, List< ValidationResult > results)
 Validates a given value against this rule. More...
 

Private Attributes

readonly IValidationRule [] _rules
 

Detailed Description

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.

var schema = new Schema().WithRule(new OrRule(new ValueComparisonRule("LT", 1),
new 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

See IValidationRule

Constructor & Destructor Documentation

◆ OrRule()

PipServices3.Commons.Validate.OrRule.OrRule ( params IValidationRule []  rules)

Creates a new validation rule and sets its values.

Parameters
rulesa list of rules to join with OR operator

Member Function Documentation

◆ Validate()

void PipServices3.Commons.Validate.OrRule.Validate ( string  path,
Schema  schema,
object  value,
List< ValidationResult results 
)

Validates a given value against this rule.

Parameters
patha dot notation path to the value.
schemaa schema this rule is called from
valuea value to be validated.
resultsa list with validation results to add new results.

Implements PipServices3.Commons.Validate.IValidationRule.


The documentation for this class was generated from the following file: