Skip to main content

Module builder

Module builder 

Source
Expand description

Key-path–driven validation builder (Rule).

Each rule is a fn predicate paired with an error value E. The predicate returns true if the field is valid; false means failure and the paired E is returned from Rule::apply.

For loading rule metadata (which field, which predicate, error code) from a CSV catalog, see the rule_csv_catalog example and examples/data/validation_catalog.csv in the crate source.

§Minimal runnable example

From the crate directory: cargo run --example basics — see examples/basics.rs.

Structs§

Rule
Binds a KpType (from #[derive(Kp)]) to a root value and a list of validation predicates.