Validation rule used to negate another rule.
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
NewNotRule
Creates a new validation rule and sets its values
NewNotRule(rule IValidationRule) *NotRule
- rule: IValidationRule - rule to be negated.
 
Methods
Validate
Validates a given value against this rule.
(c *NotRule) Validate(path string, schema ISchema, value any) []*ValidationResult
- path: string - dot notation path to the value.
 - schema: ISchema - schema this rule is called from
 - value: any - value to be validated.
 - results: []*ValidationResult - list with validation results to add new results.
 
Examples
var schema = NewSchema()
    .WithRule(NewNotRule(
        NewValueComparisonRule("EQ", 1)
    ))
 
schema.Validate(1);          // Result: error
schema.Validate(5);          // Result: no error