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

Validation rule to combine rules with AND logical operation. When all rules returns no errors, than this rule also returns no errors. When one of the rules return errors, than the rules returns all errors. More...

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

Public Member Functions

 AndRule (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 AND logical operation. When all rules returns no errors, than this rule also returns no errors. When one of the rules return errors, than the rules returns all errors.

var schema = new Schema().WithRule(new AndRule(
new ValueComparisonRule("GTE", 1),
new ValueComparisonRule("LTE", 10)
));
schema.Validate(0); // Result: 0 must be greater or equal to 1
schema.Validate(5); // Result: no error
schema.Validate(20); // Result: 20 must be letter or equal 10

See IValidationRule

Constructor & Destructor Documentation

◆ AndRule()

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

Creates a new validation rule and sets its values.

Parameters
rulesa list of rules to join with AND operator

Member Function Documentation

◆ Validate()

void PipServices3.Commons.Validate.AndRule.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: