Options
All
  • Public
  • Public/Protected
  • All
Menu

Class IncludedRule

Validation rule to check that value is included into the list of constants.

see

IValidationRule

Example

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

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

Hierarchy

  • IncludedRule

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 included to

    Returns IncludedRule

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