TypeScript object declarations
import type { Realm } from '@embabel/realm-types'
export default { name: 'movie-ratings', version: '1.0.0', types: { MovieRating: { visibility: 'public', properties: { imdbId: { identity: true, description: 'The rated film id.' }, rating: { type: 'int', validation: [{ rule: 'range', min: 1, max: 10 }] }, }, }, },} satisfies RealmThe record key is the label. properties is a record keyed by property name. A string value
is shorthand for a property’s description; an object can declare description, type
(string, int, number, boolean), identity, required, cardinality, validation,
values, metadata, annotatable and annotationVersion. parents names ancestor labels.
visibility: 'internal' corresponds to legacy internal: true; absent visibility is public.
Internal types are omitted from public discovery, not exempt from authorization.
cardinality names OPTIONAL, ONE, LIST or SET. It describes value multiplicity;
it does not grant write access. Complete precedence with required and identity, and
the portable values enumeration protocol, are not yet specified here.
Property validation
Section titled “Property validation”validation is part of the declared property, for example
validation: ["nonEmpty", { rule: "range", min: 1, max: 10 }].
A string names a rule; an object names it in rule and supplies its parameters. These are
property rules, separate from handler input/output JSON Schema. The host retains them with
the type declaration. Extraction enforces oneOf on a target property:
a record violating the declared vocabulary is dropped before persistence, as described in
extraction.
The complete rule vocabulary, nonEmpty and range parameter/default semantics, unknown-rule
behavior and enforcement across other write paths are not yet specified. Declaring a rule must not be presented as proof that every
write path enforces it. Authors needing a guaranteed handler boundary must also use the
handler schema profile.

