# validatable() function · @imqueue/validation

Source: https://imqueue.org/api/validation/latest/validation.validatable/
Published: 2026-08-01
Author: @imqueue maintainers (https://github.com/imqueue)
Package: @imqueue/validation 1.1.0 — generated reference, not hand-written

Class decorator that seals the [validate()](https://imqueue.org/api/validation/latest/validation.validate/) fields declared in this class, making them retrievable through [schemaOf()](https://imqueue.org/api/validation/latest/validation.schemaof/).

**Signature:**

```typescript
export declare function validatable(): (target: Ctor, context: ClassDecoratorContext) => void;
```
**Returns:**

(target: [Ctor](https://imqueue.org/api/validation/latest/validation.ctor/), context: ClassDecoratorContext) => void

The TC39 class decorator that seals the buffered field validators.

## Exceptions

Error if applied to anything other than a class.

## Remarks

Required on every class whose fields carry [validate()](https://imqueue.org/api/validation/latest/validation.validate/), for two independent reasons: without it [schemaOf()](https://imqueue.org/api/validation/latest/validation.schemaof/) returns `null`, and the unclaimed fields go on to contaminate the next class that is sealed.

It seals the fields declared in this class body and nothing else. Fields inherited from a sealed parent are not included, so `schemaOf(Child)` describes the child's own fields alone and an inherited field is validated only if the subclass re-declares it. [schemaOf()](https://imqueue.org/api/validation/latest/validation.schemaof/) does not walk the prototype chain either: an undecorated subclass of a sealed parent resolves to `null` rather than to the parent's schema.

## Example


```typescript
@validatable()
class Address {
    @validate(z.string().min(1))
    city!: string;
}

// A sealed class is itself usable as a validator for a nested object.
@validatable()
class Customer {
    @validate(z.string().min(1))
    name!: string;

    @validate(Address)
    address!: Address;
}
```

