pub trait Validate<C, S>where
S: Context,
Self: Sized,{
// Required method
fn validate(
self,
context: impl Into<S>,
constraint: &C,
) -> Validation<C, Self>;
}
Expand description
The validation function validates whether the given value complies to the specified constraint.
It returns a Validation
value that may be used to perform further
validations using its combinator methods and
or and_then
or get the
final result by calling the result
method.
The context provides additional information to perform the validation, for example a lookup table or some state information. It may also hold parameters needed to provide additional parameters to the error in case of a constraint violation. (see the crate level documentation for more details on how to use the context)
see the crate level documentation for details about how to implement a the
Validate
trait for custom constraints and custom types.
Required Methods§
Sourcefn validate(self, context: impl Into<S>, constraint: &C) -> Validation<C, Self>
fn validate(self, context: impl Into<S>, constraint: &C) -> Validation<C, Self>
Validates this value for being compliant to the specified constraint
C
in the given context S
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.