4.2 data
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 insidedata) is checked after every construction and after everyvar fnmethod in profiles with contracts enabled (§6.7).- The order of fields is the order of declaration; the field number for serialisation — §9.2.
Related diagnostics
See also
Source: docs/spec/oxl-standard.en.md