Skip to content

IValidator

github-actions[bot] edited this page Nov 17, 2024 · 2 revisions
API / IValidator<TValidatable, TValidationError> interface

Represents a validator, generally a callback performing the validation is enough, however there are cases when additional actions need to be performed, such as flags, when a validator is added.

interface IValidator<TValidatable extends IReadOnlyValidatable<TValidationError>, TValidationError = string>

Source reference: src/validation/IValidator.ts:10.

Generic Parameters

  • TValidatable - The instance type that is being validated.

    Type constraints: IReadOnlyValidatable<TValidationError>.

  • TValidationError - The concrete type for representing validation errors (strings, enums, numbers etc.).

    Default value: string.

Methods

  • optional onAdd - Optional, a method that gets called when the validator is configured for an object.
  • optional onRemove - Optional, a method that gets called when the validator is removed for an object.
  • validate - The method validating a given object.
Clone this wiki locally