TESSA Web API
    Preparing search index...

    Class ValidationContainer<TValue, TRawValue>

    A container class for managing value validation.

    Type Parameters

    • TValue

      Type of the resulting value for validation.

    • TRawValue = TValue

      Type of the raw value for validation. Defaults to TValue.

    Implements

    Index

    Constructors

    Properties

    getRawValue?: () => TRawValue

    Function to retrieve the raw value for validation.

    getValue?: () => TValue

    Function to retrieve the resulting value for validation.

    Accessors

    • get hasAsync(): boolean

      Indicates whether the validation container has validation function that runs asynchronously.

      Returns boolean

    • get isEmpty(): boolean

      Indicates whether the validation container has no validators.

      Returns boolean

    • get isEnabled(): boolean

      Indicates whether the validation container is enabled.

      Returns boolean

      The property only affects automatic validation when accessing the result property. In this case, validation can be performed by using validate or validateAsync methods.

      true
      
    • set isEnabled(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • get isManual(): boolean

      Indicates whether the validation container work at manual mode. In manual mode, validation results are handled by the calling code.

      Returns boolean

      When accessing the result property, it will return value that was calculated at the time of the last validate or validateAsync methods call.

      false
      
    • set isManual(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • get result(): ValidationResult

      Current validation result of value.

      Returns ValidationResult

      • If the isEnabled equals false, the result is an empty value.
      • If validation container works at manual mode (see. isManual), or has asynchronous validation function the result returned value that was calculated at the time of the last validate or validateAsync methods call.
    • set result(value: null | ValidationResult): void

      Parameters

      Returns void

    • get resultInfo(): | null
      | Partial<
          Pick<
              IValidationResultItem,
              "key"
              | "fieldName"
              | "objectName"
              | "objectType",
          >,
      >

      Additional information about validation of the object.

      Returns
          | null
          | Partial<
              Pick<
                  IValidationResultItem,
                  "key"
                  | "fieldName"
                  | "objectName"
                  | "objectType",
              >,
          >

      This is optionally used to set additional information in the validator function when creating the validation result.

      null
      
    • set resultInfo(
          value:
              | null
              | Partial<
                  Pick<
                      IValidationResultItem,
                      "key"
                      | "fieldName"
                      | "objectName"
                      | "objectType",
                  >,
              >,
      ): void

      Parameters

      • value:
            | null
            | Partial<
                Pick<
                    IValidationResultItem,
                    "key"
                    | "fieldName"
                    | "objectName"
                    | "objectType",
                >,
            >

      Returns void

    • get size(): number

      The number of validators in the container.

      Returns number

    Methods

    • Clears all validators from the container.

      Returns void

    • Returns void

    • Removes all validator functions with a specific identifier from the container.

      Parameters

      • id: string

        The identifier of the validators to remove.

      Returns boolean

      true if any validators were removed, otherwise false.

      The search by identifier is case-insensitive.

    • Validates a value using the container's only synchronous validators.

      Parameters

      • value: TValue

        The resulting value to validate.

      • OptionalrawValue: TRawValue

        The raw value to validate.

      Returns ValidationResult

      The validation result.

      If the validation container contains an asynchronous validator.

    • Validates a value using the container's all validators.

      Parameters

      • value: TValue

        The resulting value to validate.

      • OptionalrawValue: TRawValue

        The raw value to validate.

      Returns Promise<ValidationResult>

      The validation result.