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

Validation rule negate another rule. When embedded rule returns no errors, than this rule return an error. When embedded rule return errors, than the rule returns no errors. More...

Public Member Functions

 NotRule (IValidationRule rule)
 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 _rule
 

Detailed Description

Validation rule negate another rule. When embedded rule returns no errors, than this rule return an error. When embedded rule return errors, than the rule returns no errors.

var schema = new Schema().WithRule(
new NotRule(new ValueComparisonRule("EQ", 1)));
schema.Validate(1); // Result: error
schema.Validate(5); // Result: no error

See IValidationRule

Constructor & Destructor Documentation

◆ NotRule()

PipServices3.Commons.Validate.NotRule.NotRule ( IValidationRule  rule)

Creates a new validation rule and sets its values

Parameters
rulea rule to be negated.

Member Function Documentation

◆ Validate()

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

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