Available on crate feature
validate only.Expand description
Garde rules every declared schema shares. A repository’s config and a template’s own exports are held to the same rules and report the same messages.
Each one is a #[garde(custom(…))] rule. It runs at the boundary, on a
fully parsed value, and garde names the field that failed. The rules are
generic over the context. The same rule works in a schema validated
against nothing and in one validated against the whole document.
use ctl_core::validate::{at_least_one, one_file_name};
assert!(one_file_name::<()>("notes.md", &()).is_ok());
assert!(one_file_name::<()>("docs/notes.md", &()).is_err());
assert!(at_least_one::<String, ()>("label")(&[], &()).is_err());Functions§
- at_
least_ one - A rule for a list that must not be empty. The
nounnames what the list holds, in the message:at_least_one("label")reports “must declare at least one label”. - cannot_
be_ empty - A rule for a string that must not be empty. The
becausetext gives the reason, so the message explains itself. - inside_
the_ repo - A path a repository may write to: relative, and never upward out of the tree.
- one_
file_ name - One file name, so a name cannot smuggle in the path it was separated from.