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

Validation rule that compares value to a constant. More...

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

Public Member Functions

 ValueComparisonRule (string operation, object value)
 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 string _operation
 
readonly object _value
 

Detailed Description

Validation rule that compares value to a constant.

var schema = new Schema().WithRule(new ValueComparisonRule("EQ", 1));
schema.Validate(1); // Result: no errors
schema.Validate(2); // Result: 2 is not equal to 1

Constructor & Destructor Documentation

◆ ValueComparisonRule()

PipServices3.Commons.Validate.ValueComparisonRule.ValueComparisonRule ( string  operation,
object  value 
)

Creates a new validation rule and sets its values.

Parameters
operationa comparison operation.
valuea constant value to compare to

Member Function Documentation

◆ Validate()

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