Public Member Functions | Private Attributes | List of all members
PipServices3.Commons.Validate.PropertiesComparisonRule Class Reference

Validation rule that compares two object properties. More...

Inheritance diagram for PipServices3.Commons.Validate.PropertiesComparisonRule:

Public Member Functions

 PropertiesComparisonRule (string property1, string operation, string property2)
 Creates a new validation rule and sets its arguments. More...
void Validate (string path, Schema schema, object value, List< ValidationResult > results)
 Validates a given value against this rule. More...

Private Attributes

readonly string _property1
readonly string _property2
readonly string _operation

Detailed Description

Validation rule that compares two object properties.

var schema = new ObjectSchema().WithRule(new 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

See IValidationRule

Constructor & Destructor Documentation

◆ PropertiesComparisonRule()

PipServices3.Commons.Validate.PropertiesComparisonRule.PropertiesComparisonRule ( string  property1,
string  operation,
string  property2 

Creates a new validation rule and sets its arguments.

property1a name of the first property to compare.
operationa comparison operation.
property2a name of the second property to compare.

Member Function Documentation

◆ Validate()

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

Validates a given value against this rule.

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: