Options
All
  • Public
  • Public/Protected
  • All
Menu

Class NotRule

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.

see

IValidationRule

Example

let schema = new Schema()
    .withRule(new NotRule(
        new ValueComparisonRule("EQ", 1)
    ));

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

Hierarchy

  • NotRule

Implements

Index

Constructors

Methods

Constructors

constructor

  • Creates a new validation rule and sets its values

    Parameters

    Returns NotRule

Methods

validate

  • Validates a given value against this rule.

    Parameters

    • path: string

      a dot notation path to the value.

    • schema: Schema

      a schema this rule is called from

    • value: any

      a value to be validated.

    • results: ValidationResult[]

      a list with validation results to add new results.

    Returns void

Generated using TypeDoc