Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ValueComparisonRule

Validation rule that compares value to a constant.

see

IValidationRule

Example

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

schema.validate(1);          // Result: no errors
schema.validate(2);          // Result: 2 is not equal to 1

Hierarchy

  • ValueComparisonRule

Implements

Index

Constructors

Methods

Constructors

constructor

  • Creates a new validation rule and sets its values.

    Parameters

    • operation: string

      a comparison operation: "==" ("=", "EQ"), "!= " ("<>", "NE"); "<"/">" ("LT"/"GT"), "<="/">=" ("LE"/"GE"); "LIKE".

    • value: any

      a constant value to compare to

    Returns ValueComparisonRule

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