ontoref/ontology/constraints/non_empty_id.ncl

13 lines
435 B
Plaintext
Raw Permalink Normal View History

2026-03-13 00:21:04 +00:00
# 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
)