You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This module defines the validation schema protocol for ObjectStack, providing a comprehensive type-safe validation system similar to Salesforce's validation…
{/* ⚠️ AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs live in the module folders under content/docs/. */}
ObjectStack Validation Protocol
This module defines the validation schema protocol for ObjectStack, providing a comprehensive
type-safe validation system similar to Salesforce's validation rules but with enhanced capabilities.
Overview
Validation rules are applied at the data layer to ensure data integrity and enforce business logic.
A validation rule is a deterministic, synchronous, side-effect-free predicate over a single
record — it must be decidable from the incoming write (and, on update, the prior record) with
no I/O. Everything advertised here runs on the write path (see
objectql/src/validation/rule-validator.ts) — insert, single-id update, and multi-row
(multi: true) update, where the evaluator runs once per matched row (#3106); nothing is a
silent no-op. The events enum admits only insert/update for this reason — see the
delete note under "Deliberately NOT validation rules" below.
The system supports these validation types:
Script Validation: Formula-based validation using a CEL predicate
State Machine Validation: Control allowed state transitions
Format Validation: Validate a field's value (email, URL, phone, JSON, regex)
Cross-Field Validation: Validate relationships between multiple fields
JSON Schema Validation: Validate a JSON field against a JSON Schema
Conditional Validation: Apply a nested rule based on a CEL condition
Deliberately NOT validation rules
These were once declared here but never enforced. Because the contract above rules them out
(they need I/O or are client-side concerns), they were removed rather than left as silent
no-ops. Use the layer that already does each one correctly:
Uniqueness → a unique index whose scope is stated (ObjectSchema.indexes, with
unique: 'organization' for one holder per organization or unique: 'global' for one
across the whole installation — ADR-0120; partial for a scoped/conditional constraint),
or field-level unique. A SELECT-then-INSERT "rule" is inherently racy (TOCTOU); a DB
unique constraint is not.
Async / remote validation → a client-form concern (debounce/validatorUrl only mean
anything against keystrokes) and an SSRF/latency hazard on the server write path. Keep it in
the form layer, or enforce the underlying invariant with a unique index / lifecycle hook.
Custom handler → a beforeInsert / beforeUpdate lifecycle hook, the typed, supported
extension point for arbitrary validation code.
Delete-time guards (events: ['delete']) → a beforeDelete lifecycle hook. The evaluator
only runs on the insert/update write path (a delete carries no record payload to validate), so
a delete event was a proven silent no-op — the enum value was removed rather than left
advertised-but-unenforced (#3184; see docs/audits/2026-06-validationschema-property-liveness.md).
Transition gate vs invariant — which tool enforces what
A rule declared here is an INVARIANT. script (and cross_field, which shares its
evaluation path) is re-evaluated against the MERGED record — the prior row overlaid
with the incoming patch — on every write, with no exemption for a violation that was
already stored. A row that already violates is therefore refused on ANY edit until a
repairing write lands: frozen, not bricked.
The FIELD-level checks are the other half of the boundary and are deliberately not
invariants. Field.requiredWhen is a transition gate: the write is refused only
when the merged record violates AND the pre-write record complied, so a row that
predates the rule keeps passing unrelated edits and state moves that stay inside the
gate. The field bounds (min / max / minLength / maxLength) are checked on the
WRITTEN value only, so a stored out-of-bound value is never re-read at all. Both are
what lets a new rule land on a deployed object without bricking existing rows
(ADR-0113 non-regression).
Choosing between them: need an INVARIANT ("X may never exceed Y") ⇒ a validations[]script rule, at the price of freezing existing violators until they are repaired.
Need a TRANSITION CONDITION ("by the time it reaches state S, X must be present") ⇒
Field.requiredWhen or a field bound, at the price of letting rows that predate the
rule through. "Required when X" reads like an invariant and is not one — that
mis-read is what this section exists to prevent. The rules here and the field
predicates are both evaluated by evaluateValidationRules
(objectql/src/validation/rule-validator.ts); the field bounds by validateRecord
(objectql/src/validation/record-validator.ts).
Salesforce Comparison
ObjectStack validation rules are inspired by Salesforce validation rules but enhanced:
Salesforce: Formula-based validation with Error Condition Formula
ObjectStack: Multiple validation types with composable rules
Administrative notes explaining the business reason
active
boolean
optional (default: true)
events
Enum<'insert' | 'update'>[]
optional (default: ["insert","update"])
Write contexts the rule runs on. delete is intentionally absent — the evaluator only runs on the insert/update write path; guard deletions with a beforeDelete lifecycle hook
The sentence a refused write returns to the person: a {{ }} template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under record (the merged record the rule judged) or, on update, previous (the stored row), with an optional whitelisted formatter: Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }}). A single-brace {…} token, a hole over any other root or field, and logic in a hole are refused at objectstack validate, compile and the publish gate. Stays a string; translate it at objects.OBJECT._validations.RULE.message, which reads the same holes.
Administrative notes explaining the business reason
active
boolean
optional (default: true)
events
Enum<'insert' | 'update'>[]
optional (default: ["insert","update"])
Write contexts the rule runs on. delete is intentionally absent — the evaluator only runs on the insert/update write path; guard deletions with a beforeDelete lifecycle hook
The sentence a refused write returns to the person: a {{ }} template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under record (the merged record the rule judged) or, on update, previous (the stored row), with an optional whitelisted formatter: Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }}). A single-brace {…} token, a hole over any other root or field, and logic in a hole are refused at objectstack validate, compile and the publish gate. Stays a string; translate it at objects.OBJECT._validations.RULE.message, which reads the same holes.
Predicate (CEL). If TRUE, validation fails. e.g. Precord.amount != null && record.amount < 0. A TRUE INVARIANT, not a transition gate: re-evaluated against the merged record (the prior row overlaid with this write) on every write, with no exemption for a violation that was already stored — a row that already violates is refused on ANY edit until a repairing write lands (frozen, not bricked). Need a transition condition instead — one that only has to hold from a given state onward — use Field.requiredWhen or a field bound (min / max / maxLength), which judge the write rather than the stored row.
Administrative notes explaining the business reason
active
boolean
optional (default: true)
events
Enum<'insert' | 'update'>[]
optional (default: ["insert","update"])
Write contexts the rule runs on. delete is intentionally absent — the evaluator only runs on the insert/update write path; guard deletions with a beforeDelete lifecycle hook
The sentence a refused write returns to the person: a {{ }} template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under record (the merged record the rule judged) or, on update, previous (the stored row), with an optional whitelisted formatter: Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }}). A single-brace {…} token, a hole over any other root or field, and logic in a hole are refused at objectstack validate, compile and the publish gate. Stays a string; translate it at objects.OBJECT._validations.RULE.message, which reads the same holes.
Origin of the item (package | org | env-forced | platform).
_packageId
string
optional
Owning package machine id.
_packageVersion
string
optional
Owning package version.
_lockDocsUrl
string
optional
Optional documentation link surfaced next to _lockReason.
type
'state_machine'
✅
field
string
✅
State field (e.g. status)
transitions
Record<string, string[]>
✅
Map of { OldState: [AllowedNewStates] }
initialStates
string[]
optional
States a record may be CREATED in. When set, an INSERT whose state field carries a value outside this list is rejected (server-enforced) — the FSM entry point. transitions only governs UPDATE, and a select field permits ANY declared option as an initial value, so without this a record could be born mid-flow (e.g. created already approved). Omitted or empty, insert is not checked; the author-time rule state-machine-no-initial-states refuses an active machine declared that way at publish and in os validate when its events include insert (the default). An update-only machine never runs on create, so it needs no initialStates.
Administrative notes explaining the business reason
active
boolean
optional (default: true)
events
Enum<'insert' | 'update'>[]
optional (default: ["insert","update"])
Write contexts the rule runs on. delete is intentionally absent — the evaluator only runs on the insert/update write path; guard deletions with a beforeDelete lifecycle hook
The sentence a refused write returns to the person: a {{ }} template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under record (the merged record the rule judged) or, on update, previous (the stored row), with an optional whitelisted formatter: Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }}). A single-brace {…} token, a hole over any other root or field, and logic in a hole are refused at objectstack validate, compile and the publish gate. Stays a string; translate it at objects.OBJECT._validations.RULE.message, which reads the same holes.
Administrative notes explaining the business reason
active
boolean
optional (default: true)
events
Enum<'insert' | 'update'>[]
optional (default: ["insert","update"])
Write contexts the rule runs on. delete is intentionally absent — the evaluator only runs on the insert/update write path; guard deletions with a beforeDelete lifecycle hook
The sentence a refused write returns to the person: a {{ }} template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under record (the merged record the rule judged) or, on update, previous (the stored row), with an optional whitelisted formatter: Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }}). A single-brace {…} token, a hole over any other root or field, and logic in a hole are refused at objectstack validate, compile and the publish gate. Stays a string; translate it at objects.OBJECT._validations.RULE.message, which reads the same holes.
Predicate (CEL) comparing fields. If TRUE, validation fails — the condition describes the violation. e.g. Precord.end_date < record.start_date refuses an end date before the start date.
fields
string[]
✅
Fields involved. Only fields[0] is read (labels which field the violation attaches to); the rest are advisory. Shares script’s evaluation path.
Administrative notes explaining the business reason
active
boolean
optional (default: true)
events
Enum<'insert' | 'update'>[]
optional (default: ["insert","update"])
Write contexts the rule runs on. delete is intentionally absent — the evaluator only runs on the insert/update write path; guard deletions with a beforeDelete lifecycle hook
The sentence a refused write returns to the person: a {{ }} template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under record (the merged record the rule judged) or, on update, previous (the stored row), with an optional whitelisted formatter: Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }}). A single-brace {…} token, a hole over any other root or field, and logic in a hole are refused at objectstack validate, compile and the publish gate. Stays a string; translate it at objects.OBJECT._validations.RULE.message, which reads the same holes.
Administrative notes explaining the business reason
active
boolean
optional (default: true)
events
Enum<'insert' | 'update'>[]
optional (default: ["insert","update"])
Write contexts the rule runs on. delete is intentionally absent — the evaluator only runs on the insert/update write path; guard deletions with a beforeDelete lifecycle hook
The sentence a refused write returns to the person: a {{ }} template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under record (the merged record the rule judged) or, on update, previous (the stored row), with an optional whitelisted formatter: Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }}). A single-brace {…} token, a hole over any other root or field, and logic in a hole are refused at objectstack validate, compile and the publish gate. Stays a string; translate it at objects.OBJECT._validations.RULE.message, which reads the same holes.
Predicate (CEL). If TRUE, validation fails. e.g. Precord.amount != null && record.amount < 0. A TRUE INVARIANT, not a transition gate: re-evaluated against the merged record (the prior row overlaid with this write) on every write, with no exemption for a violation that was already stored — a row that already violates is refused on ANY edit until a repairing write lands (frozen, not bricked). Need a transition condition instead — one that only has to hold from a given state onward — use Field.requiredWhen or a field bound (min / max / maxLength), which judge the write rather than the stored row.
Administrative notes explaining the business reason
active
boolean
optional (default: true)
events
Enum<'insert' | 'update'>[]
optional (default: ["insert","update"])
Write contexts the rule runs on. delete is intentionally absent — the evaluator only runs on the insert/update write path; guard deletions with a beforeDelete lifecycle hook
The sentence a refused write returns to the person: a {{ }} template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under record (the merged record the rule judged) or, on update, previous (the stored row), with an optional whitelisted formatter: Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }}). A single-brace {…} token, a hole over any other root or field, and logic in a hole are refused at objectstack validate, compile and the publish gate. Stays a string; translate it at objects.OBJECT._validations.RULE.message, which reads the same holes.
Origin of the item (package | org | env-forced | platform).
_packageId
string
optional
Owning package machine id.
_packageVersion
string
optional
Owning package version.
_lockDocsUrl
string
optional
Optional documentation link surfaced next to _lockReason.
type
'state_machine'
✅
field
string
✅
State field (e.g. status)
transitions
Record<string, string[]>
✅
Map of { OldState: [AllowedNewStates] }
initialStates
string[]
optional
States a record may be CREATED in. When set, an INSERT whose state field carries a value outside this list is rejected (server-enforced) — the FSM entry point. transitions only governs UPDATE, and a select field permits ANY declared option as an initial value, so without this a record could be born mid-flow (e.g. created already approved). Omitted or empty, insert is not checked; the author-time rule state-machine-no-initial-states refuses an active machine declared that way at publish and in os validate when its events include insert (the default). An update-only machine never runs on create, so it needs no initialStates.
Administrative notes explaining the business reason
active
boolean
optional (default: true)
events
Enum<'insert' | 'update'>[]
optional (default: ["insert","update"])
Write contexts the rule runs on. delete is intentionally absent — the evaluator only runs on the insert/update write path; guard deletions with a beforeDelete lifecycle hook
The sentence a refused write returns to the person: a {{ }} template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under record (the merged record the rule judged) or, on update, previous (the stored row), with an optional whitelisted formatter: Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }}). A single-brace {…} token, a hole over any other root or field, and logic in a hole are refused at objectstack validate, compile and the publish gate. Stays a string; translate it at objects.OBJECT._validations.RULE.message, which reads the same holes.
Administrative notes explaining the business reason
active
boolean
optional (default: true)
events
Enum<'insert' | 'update'>[]
optional (default: ["insert","update"])
Write contexts the rule runs on. delete is intentionally absent — the evaluator only runs on the insert/update write path; guard deletions with a beforeDelete lifecycle hook
The sentence a refused write returns to the person: a {{ }} template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under record (the merged record the rule judged) or, on update, previous (the stored row), with an optional whitelisted formatter: Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }}). A single-brace {…} token, a hole over any other root or field, and logic in a hole are refused at objectstack validate, compile and the publish gate. Stays a string; translate it at objects.OBJECT._validations.RULE.message, which reads the same holes.
Predicate (CEL) comparing fields. If TRUE, validation fails — the condition describes the violation. e.g. Precord.end_date < record.start_date refuses an end date before the start date.
fields
string[]
✅
Fields involved. Only fields[0] is read (labels which field the violation attaches to); the rest are advisory. Shares script’s evaluation path.
Administrative notes explaining the business reason
active
boolean
optional (default: true)
events
Enum<'insert' | 'update'>[]
optional (default: ["insert","update"])
Write contexts the rule runs on. delete is intentionally absent — the evaluator only runs on the insert/update write path; guard deletions with a beforeDelete lifecycle hook
The sentence a refused write returns to the person: a {{ }} template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under record (the merged record the rule judged) or, on update, previous (the stored row), with an optional whitelisted formatter: Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }}). A single-brace {…} token, a hole over any other root or field, and logic in a hole are refused at objectstack validate, compile and the publish gate. Stays a string; translate it at objects.OBJECT._validations.RULE.message, which reads the same holes.
Origin of the item (package | org | env-forced | platform).
_packageId
string
optional
Owning package machine id.
_packageVersion
string
optional
Owning package version.
_lockDocsUrl
string
optional
Optional documentation link surfaced next to _lockReason.
type
'json_schema'
✅
field
string
✅
JSON field to validate
schema
Record<string, any>
✅
JSON Schema object definition
CrossFieldValidation
Properties
Property
Type
Required
Description
name
string
✅
Unique rule name (snake_case)
label
string
optional
Human-readable label for the rule listing
description
string
optional
Administrative notes explaining the business reason
active
boolean
optional (default: true)
events
Enum<'insert' | 'update'>[]
optional (default: ["insert","update"])
Write contexts the rule runs on. delete is intentionally absent — the evaluator only runs on the insert/update write path; guard deletions with a beforeDelete lifecycle hook
The sentence a refused write returns to the person: a {{ }} template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under record (the merged record the rule judged) or, on update, previous (the stored row), with an optional whitelisted formatter: Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }}). A single-brace {…} token, a hole over any other root or field, and logic in a hole are refused at objectstack validate, compile and the publish gate. Stays a string; translate it at objects.OBJECT._validations.RULE.message, which reads the same holes.
Predicate (CEL) comparing fields. If TRUE, validation fails — the condition describes the violation. e.g. Precord.end_date < record.start_date refuses an end date before the start date.
fields
string[]
✅
Fields involved. Only fields[0] is read (labels which field the violation attaches to); the rest are advisory. Shares script’s evaluation path.
FormatValidation
Properties
Property
Type
Required
Description
name
string
✅
Unique rule name (snake_case)
label
string
optional
Human-readable label for the rule listing
description
string
optional
Administrative notes explaining the business reason
active
boolean
optional (default: true)
events
Enum<'insert' | 'update'>[]
optional (default: ["insert","update"])
Write contexts the rule runs on. delete is intentionally absent — the evaluator only runs on the insert/update write path; guard deletions with a beforeDelete lifecycle hook
The sentence a refused write returns to the person: a {{ }} template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under record (the merged record the rule judged) or, on update, previous (the stored row), with an optional whitelisted formatter: Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }}). A single-brace {…} token, a hole over any other root or field, and logic in a hole are refused at objectstack validate, compile and the publish gate. Stays a string; translate it at objects.OBJECT._validations.RULE.message, which reads the same holes.
Origin of the item (package | org | env-forced | platform).
_packageId
string
optional
Owning package machine id.
_packageVersion
string
optional
Owning package version.
_lockDocsUrl
string
optional
Optional documentation link surfaced next to _lockReason.
type
'format'
✅
field
string
✅
regex
string
optional
format
Enum<'email' | 'url' | 'phone' | 'json'>
optional
JSONValidation
Properties
Property
Type
Required
Description
name
string
✅
Unique rule name (snake_case)
label
string
optional
Human-readable label for the rule listing
description
string
optional
Administrative notes explaining the business reason
active
boolean
optional (default: true)
events
Enum<'insert' | 'update'>[]
optional (default: ["insert","update"])
Write contexts the rule runs on. delete is intentionally absent — the evaluator only runs on the insert/update write path; guard deletions with a beforeDelete lifecycle hook
The sentence a refused write returns to the person: a {{ }} template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under record (the merged record the rule judged) or, on update, previous (the stored row), with an optional whitelisted formatter: Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }}). A single-brace {…} token, a hole over any other root or field, and logic in a hole are refused at objectstack validate, compile and the publish gate. Stays a string; translate it at objects.OBJECT._validations.RULE.message, which reads the same holes.
Origin of the item (package | org | env-forced | platform).
_packageId
string
optional
Owning package machine id.
_packageVersion
string
optional
Owning package version.
_lockDocsUrl
string
optional
Optional documentation link surfaced next to _lockReason.
type
'json_schema'
✅
field
string
✅
JSON field to validate
schema
Record<string, any>
✅
JSON Schema object definition
ScriptValidation
Properties
Property
Type
Required
Description
name
string
✅
Unique rule name (snake_case)
label
string
optional
Human-readable label for the rule listing
description
string
optional
Administrative notes explaining the business reason
active
boolean
optional (default: true)
events
Enum<'insert' | 'update'>[]
optional (default: ["insert","update"])
Write contexts the rule runs on. delete is intentionally absent — the evaluator only runs on the insert/update write path; guard deletions with a beforeDelete lifecycle hook
The sentence a refused write returns to the person: a {{ }} template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under record (the merged record the rule judged) or, on update, previous (the stored row), with an optional whitelisted formatter: Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }}). A single-brace {…} token, a hole over any other root or field, and logic in a hole are refused at objectstack validate, compile and the publish gate. Stays a string; translate it at objects.OBJECT._validations.RULE.message, which reads the same holes.
Predicate (CEL). If TRUE, validation fails. e.g. Precord.amount != null && record.amount < 0. A TRUE INVARIANT, not a transition gate: re-evaluated against the merged record (the prior row overlaid with this write) on every write, with no exemption for a violation that was already stored — a row that already violates is refused on ANY edit until a repairing write lands (frozen, not bricked). Need a transition condition instead — one that only has to hold from a given state onward — use Field.requiredWhen or a field bound (min / max / maxLength), which judge the write rather than the stored row.
StateMachineValidation
Properties
Property
Type
Required
Description
name
string
✅
Unique rule name (snake_case)
label
string
optional
Human-readable label for the rule listing
description
string
optional
Administrative notes explaining the business reason
active
boolean
optional (default: true)
events
Enum<'insert' | 'update'>[]
optional (default: ["insert","update"])
Write contexts the rule runs on. delete is intentionally absent — the evaluator only runs on the insert/update write path; guard deletions with a beforeDelete lifecycle hook
The sentence a refused write returns to the person: a {{ }} template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under record (the merged record the rule judged) or, on update, previous (the stored row), with an optional whitelisted formatter: Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }}). A single-brace {…} token, a hole over any other root or field, and logic in a hole are refused at objectstack validate, compile and the publish gate. Stays a string; translate it at objects.OBJECT._validations.RULE.message, which reads the same holes.
Origin of the item (package | org | env-forced | platform).
_packageId
string
optional
Owning package machine id.
_packageVersion
string
optional
Owning package version.
_lockDocsUrl
string
optional
Optional documentation link surfaced next to _lockReason.
type
'state_machine'
✅
field
string
✅
State field (e.g. status)
transitions
Record<string, string[]>
✅
Map of { OldState: [AllowedNewStates] }
initialStates
string[]
optional
States a record may be CREATED in. When set, an INSERT whose state field carries a value outside this list is rejected (server-enforced) — the FSM entry point. transitions only governs UPDATE, and a select field permits ANY declared option as an initial value, so without this a record could be born mid-flow (e.g. created already approved). Omitted or empty, insert is not checked; the author-time rule state-machine-no-initial-states refuses an active machine declared that way at publish and in os validate when its events include insert (the default). An update-only machine never runs on create, so it needs no initialStates.
ValidationRule
Union Options
This schema accepts one of the following structures:
Option 1
Type:script
Properties
Property
Type
Required
Description
name
string
✅
Unique rule name (snake_case)
label
string
optional
Human-readable label for the rule listing
description
string
optional
Administrative notes explaining the business reason
active
boolean
optional (default: true)
events
Enum<'insert' | 'update'>[]
optional (default: ["insert","update"])
Write contexts the rule runs on. delete is intentionally absent — the evaluator only runs on the insert/update write path; guard deletions with a beforeDelete lifecycle hook
The sentence a refused write returns to the person: a {{ }} template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under record (the merged record the rule judged) or, on update, previous (the stored row), with an optional whitelisted formatter: Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }}). A single-brace {…} token, a hole over any other root or field, and logic in a hole are refused at objectstack validate, compile and the publish gate. Stays a string; translate it at objects.OBJECT._validations.RULE.message, which reads the same holes.
Predicate (CEL). If TRUE, validation fails. e.g. Precord.amount != null && record.amount < 0. A TRUE INVARIANT, not a transition gate: re-evaluated against the merged record (the prior row overlaid with this write) on every write, with no exemption for a violation that was already stored — a row that already violates is refused on ANY edit until a repairing write lands (frozen, not bricked). Need a transition condition instead — one that only has to hold from a given state onward — use Field.requiredWhen or a field bound (min / max / maxLength), which judge the write rather than the stored row.
Option 2
Type:state_machine
Properties
Property
Type
Required
Description
name
string
✅
Unique rule name (snake_case)
label
string
optional
Human-readable label for the rule listing
description
string
optional
Administrative notes explaining the business reason
active
boolean
optional (default: true)
events
Enum<'insert' | 'update'>[]
optional (default: ["insert","update"])
Write contexts the rule runs on. delete is intentionally absent — the evaluator only runs on the insert/update write path; guard deletions with a beforeDelete lifecycle hook
The sentence a refused write returns to the person: a {{ }} template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under record (the merged record the rule judged) or, on update, previous (the stored row), with an optional whitelisted formatter: Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }}). A single-brace {…} token, a hole over any other root or field, and logic in a hole are refused at objectstack validate, compile and the publish gate. Stays a string; translate it at objects.OBJECT._validations.RULE.message, which reads the same holes.
Origin of the item (package | org | env-forced | platform).
_packageId
string
optional
Owning package machine id.
_packageVersion
string
optional
Owning package version.
_lockDocsUrl
string
optional
Optional documentation link surfaced next to _lockReason.
type
'state_machine'
✅
field
string
✅
State field (e.g. status)
transitions
Record<string, string[]>
✅
Map of { OldState: [AllowedNewStates] }
initialStates
string[]
optional
States a record may be CREATED in. When set, an INSERT whose state field carries a value outside this list is rejected (server-enforced) — the FSM entry point. transitions only governs UPDATE, and a select field permits ANY declared option as an initial value, so without this a record could be born mid-flow (e.g. created already approved). Omitted or empty, insert is not checked; the author-time rule state-machine-no-initial-states refuses an active machine declared that way at publish and in os validate when its events include insert (the default). An update-only machine never runs on create, so it needs no initialStates.
Option 3
Type:format
Properties
Property
Type
Required
Description
name
string
✅
Unique rule name (snake_case)
label
string
optional
Human-readable label for the rule listing
description
string
optional
Administrative notes explaining the business reason
active
boolean
optional (default: true)
events
Enum<'insert' | 'update'>[]
optional (default: ["insert","update"])
Write contexts the rule runs on. delete is intentionally absent — the evaluator only runs on the insert/update write path; guard deletions with a beforeDelete lifecycle hook
The sentence a refused write returns to the person: a {{ }} template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under record (the merged record the rule judged) or, on update, previous (the stored row), with an optional whitelisted formatter: Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }}). A single-brace {…} token, a hole over any other root or field, and logic in a hole are refused at objectstack validate, compile and the publish gate. Stays a string; translate it at objects.OBJECT._validations.RULE.message, which reads the same holes.
Origin of the item (package | org | env-forced | platform).
_packageId
string
optional
Owning package machine id.
_packageVersion
string
optional
Owning package version.
_lockDocsUrl
string
optional
Optional documentation link surfaced next to _lockReason.
type
'format'
✅
field
string
✅
regex
string
optional
format
Enum<'email' | 'url' | 'phone' | 'json'>
optional
Option 4
Type:cross_field
Properties
Property
Type
Required
Description
name
string
✅
Unique rule name (snake_case)
label
string
optional
Human-readable label for the rule listing
description
string
optional
Administrative notes explaining the business reason
active
boolean
optional (default: true)
events
Enum<'insert' | 'update'>[]
optional (default: ["insert","update"])
Write contexts the rule runs on. delete is intentionally absent — the evaluator only runs on the insert/update write path; guard deletions with a beforeDelete lifecycle hook
The sentence a refused write returns to the person: a {{ }} template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under record (the merged record the rule judged) or, on update, previous (the stored row), with an optional whitelisted formatter: Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }}). A single-brace {…} token, a hole over any other root or field, and logic in a hole are refused at objectstack validate, compile and the publish gate. Stays a string; translate it at objects.OBJECT._validations.RULE.message, which reads the same holes.
Predicate (CEL) comparing fields. If TRUE, validation fails — the condition describes the violation. e.g. Precord.end_date < record.start_date refuses an end date before the start date.
fields
string[]
✅
Fields involved. Only fields[0] is read (labels which field the violation attaches to); the rest are advisory. Shares script’s evaluation path.
Option 5
Type:json_schema
Properties
Property
Type
Required
Description
name
string
✅
Unique rule name (snake_case)
label
string
optional
Human-readable label for the rule listing
description
string
optional
Administrative notes explaining the business reason
active
boolean
optional (default: true)
events
Enum<'insert' | 'update'>[]
optional (default: ["insert","update"])
Write contexts the rule runs on. delete is intentionally absent — the evaluator only runs on the insert/update write path; guard deletions with a beforeDelete lifecycle hook
The sentence a refused write returns to the person: a {{ }} template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under record (the merged record the rule judged) or, on update, previous (the stored row), with an optional whitelisted formatter: Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }}). A single-brace {…} token, a hole over any other root or field, and logic in a hole are refused at objectstack validate, compile and the publish gate. Stays a string; translate it at objects.OBJECT._validations.RULE.message, which reads the same holes.
Origin of the item (package | org | env-forced | platform).
_packageId
string
optional
Owning package machine id.
_packageVersion
string
optional
Owning package version.
_lockDocsUrl
string
optional
Optional documentation link surfaced next to _lockReason.
type
'json_schema'
✅
field
string
✅
JSON field to validate
schema
Record<string, any>
✅
JSON Schema object definition
Option 6
Type:conditional
Properties
Property
Type
Required
Description
name
string
✅
Unique rule name (snake_case)
label
string
optional
Human-readable label for the rule listing
description
string
optional
Administrative notes explaining the business reason
active
boolean
optional (default: true)
events
Enum<'insert' | 'update'>[]
optional (default: ["insert","update"])
Write contexts the rule runs on. delete is intentionally absent — the evaluator only runs on the insert/update write path; guard deletions with a beforeDelete lifecycle hook
The sentence a refused write returns to the person: a {{ }} template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under record (the merged record the rule judged) or, on update, previous (the stored row), with an optional whitelisted formatter: Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }}). A single-brace {…} token, a hole over any other root or field, and logic in a hole are refused at objectstack validate, compile and the publish gate. Stays a string; translate it at objects.OBJECT._validations.RULE.message, which reads the same holes.