ontoref/ontology/constraints/non_empty_id.ncl
Jesús Pérez 0396e4037b
Some checks failed
Nickel Type Check / Nickel Type Checking (push) Has been cancelled
Rust CI / Security Audit (push) Has been cancelled
Rust CI / Check + Test + Lint (nightly) (push) Has been cancelled
Rust CI / Check + Test + Lint (stable) (push) Has been cancelled
chore: add ontology and reflection
2026-03-13 00:21:04 +00:00

13 lines
435 B
Plaintext

# NonEmptyId: ensures the `id` field of any record is a non-empty string.
# Apply as: `data | c.NonEmptyId` before merging with schema.
std.contract.custom (
fun label =>
fun value =>
if !(std.record.has_field "id" value) then
'Error { message = "record must have an 'id' field" }
else if std.string.length value.id == 0 then
'Error { message = "id must not be empty" }
else
'Ok value
)