OxL Reference

kw invariant

Contextual keyword — body of data (§4.2)

The list of words: §1.4

Syntax

ebnf
Member      = Field | "embed" Type | "invariant" Expr ;

Grammar: App. A

Defined in

Examples

oxl
pub(api) data User {
  pub(api) id: UserId
  pub(api) name: Name
  pub(api) email: Email?           @since(2)
  role: Role = Role.User
  createdAt: Time = now()
  invariant name != "admin" || role == Role.Admin
}

— 4.2 data

Related diagnostics

unknown-field, bad-init, missing-field, must-close, positional-literal, sealed-literal, contract

See also