Skip to content

Function.Validatable

github-actions[bot] edited this page Jun 2, 2026 · 19 revisions

umt / Validatable

Function: Validatable()

Validatable<T>(base): T

Defined in: Decorator/Validatable.ts:28

Class decorator that validates every decorated field when an instance is constructed. Throws an Error joining all failure messages when validation fails, so an invalid instance can never escape its constructor.

Validation runs after the wrapped constructor finishes, so it observes the fully initialized instance regardless of the useDefineForClassFields setting.

Type Parameters

T

T extends AnyConstructor

The decorated constructor type.

Parameters

base

T

The class being decorated.

Returns

T

A subclass that validates on construction.

Example

@Validatable
class Product {
  @IsNumber price = 0;
}
new Product(); // throws when price is not a number

API

Classes

Interfaces

Type Aliases

Variables

Functions

Clone this wiki locally