Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit3bb1da2647

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:

  1. Reads the value's identity — a bare string, or a table's __ref / guid / identity / name.
  2. Resolves it as a .data instance (asset.resolve(identity, "data")).
  3. Delegates to the instance's own ref:satisfies(constraint.contract) — the same contract-chain check data.assetType exposes 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 the dataContract kind.