Validators
Checked, not run
comline build verifies validators — an unknown validator name, a keyword
argument that isn't a property or whose literal type is wrong, or an
undeclared params.* reference all fail the build. Running them against data
(in generated code) is not done yet — see the
design note.
A validator is a named, parameterised check you attach to a struct or error field.
Properties
name: Type [= default], one per line — the same shape as a
struct field, minus optional and annotations. They are
the validator's configuration, supplied where the validator is used.
validate
A validate block holds one or more assert(condition, message) calls.
condition— member paths overvalue.*(the field under check) andparams.*(this validator's properties), compared with== != >= <= > <and joined byand/or.assert(c, m)passes whencis true.message— an interpolated string;{value.…}and{params.…}placeholders are substituted.
The condition language is deliberately small and non-computational — no precedence, no loops, no bindings.
Using one — @validators
Attach validators to a field with the @validators annotation: a list of calls
that bind the validator's properties by name.
Unbound properties fall back to their declared default. Errors' fields take
@validators too.