Builtin Library
README.md
data_contract (module)
The dataContract field-constraint validator. Registers itself with
field_constraints.module's registry on load so any component field
carrying constraint = { kind = "dataContract", contract = ... } —
which is exactly what Field.dataRef emits — is checked against it.
What it does
Given a field's written value and its constraint:
- Reads the value's identity — a bare string, or a table's
__ref/guid/identity/name. - Resolves it as a
.datainstance (asset.resolve(identity, "data")). - Delegates to the instance's own
ref:satisfies(constraint.contract)— the same contract-chain checkdata.assetTypeexposes to authored code — and returns its(ok, reason?)result verbatim.
A value that isn't resolvable as a .data instance (wrong category, or
no such asset) is rejected with a plain reason rather than crashing
through to asset.resolve's error.
Exports
M.check(value, constraint) -> ok, reason?— the validator function, also registered under thedataContractkind.