Skip to main content

Module validate

Module validate 

Source
Expand description

Garde rules every declared schema shares. Garde rules every declared schema shares, so a repository’s config and a template’s own exports are held to the same rules and complain the same way.

Each one is a #[garde(custom(…))] rule: it runs at the boundary, on a fully parsed value, and garde names the field that failed. They are generic over the context, so the same rule works in a schema validated against nothing and in one validated against the whole document.

Functions§

at_least_one
A list a schema needs something in, complaining in the repository’s own words: at_least_one("label") says “must declare at least one label”.
cannot_be_empty
A value a schema cannot do without, told what it is for, so the complaint reads like a sentence: “cannot be empty — it is what marks a template”.
inside_the_repo
Somewhere a repository may write: relative, and never upward out of the tree. A rooted path without a drive (\x on Windows) or a drive-relative one (C:x) is not absolute, yet joining it replaces the repository root, so any root or prefix component is refused too.
one_file_name
One file name, so a name cannot smuggle in the path it was separated from.