pub trait Validator {
// Required methods
fn meta(&self) -> &Meta;
fn meta_mut(&mut self) -> &mut Meta;
fn check(&self, value: &mut Value) -> Result<(), Error>;
// Provided method
fn validate(&self, value: &mut Value) -> Result<(), Error> { ... }
}Expand description
A validator: a rule (check) plus human-facing Meta.
Each validator stores a Meta and returns it from meta. check is the
rule; it receives &mut Value (not LocatedValue) so it can coerce in place — e.g. a numeric
string into an integer. validate is provided: it runs check, attaches
this validator’s Meta to any error (innermost wins), and applies the output conversion in
meta().convert on success. Composite validators recurse by calling validate on their
children, then attach the child’s Location via Error::under_key/Error::under_index.
Required Methods§
Provided Methods§
Trait Implementations§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".