Options
All
  • Public
  • Public/Protected
  • All
Menu

Module controls/Validation

Type aliases

StateValidationFunction

StateValidationFunction<TState>: function

State validation function

Takes a Control state object and returns true if the state passes validation. If validation fails, a ValidationResult object is returned instead.

Type parameters

  • TState

Type declaration

ValidationFailure

ValidationFailure: object

Describes a validation failure.

Usage:

  • A reason code should be provided that uniquely describes the kind of validation failure. A reason code is useful for context-specific rendering and other business function. It is not mandatory as for some simple cases it may be duplicative to provide both a reason code and a single rendering of that reason code.

  • A rendered reason for situations where the rendered form is not context-sensitive and can be conveniently provided when the ValidationFailure is instantiated.

Type declaration

  • Optional reasonCode?: undefined | string

    A code representing what validation failed.

    Usage:

    • use reasonCode for business logic and transform to a prompt during the rendering phase.
  • Optional renderedReason?: undefined | string

    A rendered prompt fragment that can be directly included in the Response.

    Usage:

    • If convenient, generate the prompt fragment at instantiation time.
    • A renderedReason should not be used in logic or further transformed.

Functions

evaluateValidationProp

  • Helper to evaluate a prop that accepts one or more StateValidationFunction functions.

    Type parameters

    • TState

    Parameters

    Returns Promise<true | ValidationFailure>