pub trait Validator: Send + Sync {
// Required methods
fn validate(
&self,
attribute: &str,
value: Option<&Value>,
errors: &mut Errors,
);
fn name(&self) -> &str;
fn options(&self) -> &ValidatorOptions;
// Provided method
fn validate_with_attrs(
&self,
attribute: &str,
value: Option<&Value>,
_attrs: &dyn Fn(&str) -> Option<Value>,
errors: &mut Errors,
) { ... }
}Expand description
A validation rule that can check a value and report errors.
Required Methods§
Sourcefn validate(&self, attribute: &str, value: Option<&Value>, errors: &mut Errors)
fn validate(&self, attribute: &str, value: Option<&Value>, errors: &mut Errors)
Validates a single attribute value, adding any produced errors.
Sourcefn options(&self) -> &ValidatorOptions
fn options(&self) -> &ValidatorOptions
Returns the common runtime options for this validator.