NotRule

Validation rule used to negate another rule.

Implements: IValidationRule

Description

The NotRule class allows you to negate a rule. Thus, when the embedded rule returns errors, then the negated rule returns no errors and vice versa.

Constructors

Creates a new validation rule and sets its values

NotRule(IValidationRule? rule)

Instance methods

validate

Validates a given value against this rule.

void validate(String? path, Schema schema, dynamic value, List<ValidationRule> results)

  • path: String? - dot notation path to the value.
  • schema: Schema - schema this rule is called from
  • value: dynamic - value to be validated.
  • results: List<ValidationRule> - list with validation results to add new results.

Examples

var schema =  Schema()
    .withRule( NotRule(
         ValueComparisonRule('EQ', 1)
    ));

schema.validate(1);          // Result: error
schema.validate(5);          // Result: no error

See also