Skip to content

Function: InvariantMethod() ​

InvariantMethod(message): (target, _prop, descriptor) => void

Defined in: src/decorators.ts:48

Declare a static method as a model-level invariant: it receives the model and returns false (or a message) when violated. Checked by validate(), transaction() and atomic fill().

Parameters ​

message ​

string

shown when the method returns false

Returns ​

(target, _prop, descriptor) => void

Example ​

ts
@InvariantMethod('end must not be before start')
static endAfterStart (trip: Trip) { return trip.end >= trip.start }