Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ExcludedRule

Validation rule to check that value is excluded from the list of constants.

see

IValidationRule

Example

let schema = new Schema()
    .withRule(new ExcludedRule(1, 2, 3));

schema.validate(2);      // Result: 2 must not be one of 1, 2, 3
schema.validate(10);     // Result: no errors

Hierarchy

  • ExcludedRule

Implements

Index

Constructors

Methods

Constructors

constructor

  • Creates a new validation rule and sets its values.

    Parameters

    • Rest ...values: any[]

      a list of constants that value must be excluded from

    Returns ExcludedRule

Methods

validate

  • Validates the given value. None of the values set in this ExcludedRule object must exist in the value that is given for validation to pass.

    Parameters

    • path: string

      the dot notation path to the value that is to be validated.

    • schema: Schema

      (not used in this implementation).

    • value: any

      the value that is to be validated.

    • results: ValidationResult[]

      the results of the validation.

    Returns void

Generated using TypeDoc