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

Validation rule to check that value is included into the list of constants. More...

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

Public Member Functions

 IncludedRule (params object[] values)
 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 object [] _values
 

Detailed Description

Validation rule to check that value is included into the list of constants.

var schema = new Schema().WithRule(new IncludedRule(1, 2, 3));
schema.Validate(2); // Result: no errors
schema.Validate(10); // Result: 10 must be one of 1, 2, 3

See IValidationRule

Constructor & Destructor Documentation

◆ IncludedRule()

PipServices3.Commons.Validate.IncludedRule.IncludedRule ( params object []  values)

Creates a new validation rule and sets its values.

Parameters
valuesa list of constants that value must be included to

Member Function Documentation

◆ Validate()

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