OxL Reference

4.2 data

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
}
  • A field: visibility? name: Type (= default_value)? attributes*. Field attributes MAY stand before the field or after the type on the same line.
  • The default expression is evaluated on every creation of a value and MAY refer to the preceding fields.
  • invariant expr (a contextual word inside data) is checked after every construction and after every var fn method in profiles with contracts enabled (§6.7).
  • The order of fields is the order of declaration; the field number for serialisation — §9.2.

unknown-field

See also

Source: docs/spec/oxl-standard.en.md