Skip to content

Type Alias: ActiveFieldDescriptor<_T> ​

ActiveFieldDescriptor<_T> = object

Defined in: src/types.ts:172

Options of the @ActiveField() decorator.

Type Parameters ​

_T ​

_T = unknown

Properties ​

attribute? ​

optional attribute?: AttributeValue

Defined in: src/types.ts:188

Default for a key absent from create() data (a value or a () => value factory).


coerce? ​

optional coerce?: CoerceTo

Defined in: src/types.ts:200

Convert the written value ('42' to 42, 'true' to true, a date string to a Date, or with a class such as Decimal/Money/LocalDate to an instance of it); an impossible conversion is refused.


container? ​

optional container?: ContainerSpec

Defined in: src/types.ts:234

Keep the value in a typed container that accepts nothing but one model: ActiveCollection.field(Model, options), ActiveMap.field(Model, { key }) or ActiveSet.field(Model, options). An assigned array (or Map, object, Set) is converted; the default is an empty container.


factory? ​

optional factory?: FactoryConfig

Defined in: src/types.ts:223

Wrap a nested object (or every array item) in this ActiveModel; [Model, () => default] adds a default.


fillable? ​

optional fillable?: boolean

Defined in: src/types.ts:184

false: data can never set the field and direct assignment throws. Default true.


getter? ​

optional getter?: Getter<any>

Defined in: src/types.ts:176

Compute the value returned on read.


hidden? ​

optional hidden?: boolean

Defined in: src/types.ts:182

Excluded from Object.keys, spread, in, JSON.stringify and isTouched(); still readable directly.


lowercase? ​

optional lowercase?: boolean

Defined in: src/types.ts:196

Lower-case a string.


many? ​

optional many?: boolean

Defined in: src/types.ts:228

With factory: false refuses an array, true refuses a single object (a TypeError); unset accepts both, since the field's declared type is erased at runtime.


max? ​

optional max?: Bound

Defined in: src/types.ts:208

Largest allowed number, date or value object.


maxLength? ​

optional maxLength?: number

Defined in: src/types.ts:212

Most characters / items.


min? ​

optional min?: Bound

Defined in: src/types.ts:206

Smallest allowed number, date or value object (Decimal, Money, LocalDate).


minLength? ​

optional minLength?: number

Defined in: src/types.ts:210

Fewest characters / items.


on? ​

optional on?: Partial<Record<PropEvent, ActiveModelHookListener>>

Defined in: src/types.ts:236

Field-level hooks, shared by every instance of the class (and subclasses).


once? ​

optional once?: Partial<Record<PropEvent, ActiveModelHookListener>>

Defined in: src/types.ts:238

Like on, but each hook fires only once.


oneOf? ​

optional oneOf?: readonly unknown[] | Record<string, unknown>

Defined in: src/types.ts:216

Allowed values: an array or a TypeScript enum.


pattern? ​

optional pattern?: RegExp

Defined in: src/types.ts:214

A string must match.


protected? ​

optional protected?: boolean

Defined in: src/types.ts:186

true (default): delete model.field throws.


readonly? ​

optional readonly?: boolean

Defined in: src/types.ts:180

Can be set once at creation (factory or constructor); later writes are silently ignored.


required? ​

optional required?: boolean

Defined in: src/types.ts:202

The value must not be null, undefined or ''. Also checked by validate(), which catches a field that was never set.


setter? ​

optional setter?: Setter<any>

Defined in: src/types.ts:174

Transform/intercept a write. Return true when the value was stored.


transform? ​

optional transform?: Transform | Transform[]

Defined in: src/types.ts:192

Normalizers, run first and in order: (value, { model, prop }) => newValue.


transitions? ​

optional transitions?: Transitions

Defined in: src/types.ts:221

Allowed state changes: { new: ['paid', 'cancelled'], paid: ['shipped'] }. A state with no entry is terminal; the first value (from undefined/null) and creation from data are unrestricted.


trim? ​

optional trim?: boolean

Defined in: src/types.ts:194

Trim surrounding whitespace of a string.


type? ​

optional type?: ValueType | Coercible

Defined in: src/types.ts:204

Runtime type of the value (coerce implies one).


uppercase? ​

optional uppercase?: boolean

Defined in: src/types.ts:198

Upper-case a string.


validator? ​

optional validator?: Validator<any>

Defined in: src/types.ts:178

Reject a value by throwing. Runs only when the value actually changes; the return value is ignored.


value? ​

optional value?: AttributeValue

Defined in: src/types.ts:190

Alias for attribute.