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?
optionalattribute?:AttributeValue
Defined in: src/types.ts:188
Default for a key absent from create() data (a value or a () => value factory).
coerce?
optionalcoerce?: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?
optionalcontainer?: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?
optionalfactory?:FactoryConfig
Defined in: src/types.ts:223
Wrap a nested object (or every array item) in this ActiveModel; [Model, () => default] adds a default.
fillable?
optionalfillable?:boolean
Defined in: src/types.ts:184
false: data can never set the field and direct assignment throws. Default true.
getter?
optionalgetter?:Getter<any>
Defined in: src/types.ts:176
Compute the value returned on read.
hidden?
optionalhidden?:boolean
Defined in: src/types.ts:182
Excluded from Object.keys, spread, in, JSON.stringify and isTouched(); still readable directly.
lowercase?
optionallowercase?:boolean
Defined in: src/types.ts:196
Lower-case a string.
many?
optionalmany?: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?
optionalmax?:Bound
Defined in: src/types.ts:208
Largest allowed number, date or value object.
maxLength?
optionalmaxLength?:number
Defined in: src/types.ts:212
Most characters / items.
min?
optionalmin?:Bound
Defined in: src/types.ts:206
Smallest allowed number, date or value object (Decimal, Money, LocalDate).
minLength?
optionalminLength?:number
Defined in: src/types.ts:210
Fewest characters / items.
on?
optionalon?:Partial<Record<PropEvent,ActiveModelHookListener>>
Defined in: src/types.ts:236
Field-level hooks, shared by every instance of the class (and subclasses).
once?
optionalonce?:Partial<Record<PropEvent,ActiveModelHookListener>>
Defined in: src/types.ts:238
Like on, but each hook fires only once.
oneOf?
optionaloneOf?: readonlyunknown[] |Record<string,unknown>
Defined in: src/types.ts:216
Allowed values: an array or a TypeScript enum.
pattern?
optionalpattern?:RegExp
Defined in: src/types.ts:214
A string must match.
protected?
optionalprotected?:boolean
Defined in: src/types.ts:186
true (default): delete model.field throws.
readonly?
optionalreadonly?:boolean
Defined in: src/types.ts:180
Can be set once at creation (factory or constructor); later writes are silently ignored.
required?
optionalrequired?: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?
optionalsetter?:Setter<any>
Defined in: src/types.ts:174
Transform/intercept a write. Return true when the value was stored.
transform?
Defined in: src/types.ts:192
Normalizers, run first and in order: (value, { model, prop }) => newValue.
transitions?
optionaltransitions?: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?
optionaltrim?:boolean
Defined in: src/types.ts:194
Trim surrounding whitespace of a string.
type?
Defined in: src/types.ts:204
Runtime type of the value (coerce implies one).
uppercase?
optionaluppercase?:boolean
Defined in: src/types.ts:198
Upper-case a string.
validator?
optionalvalidator?: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?
optionalvalue?:AttributeValue
Defined in: src/types.ts:190
Alias for attribute.