Skip to main content

Rule

Trait Rule 

Source
pub trait Rule:
    Send
    + Sync
    + 'static {
    // Required methods
    fn name(&self) -> Cow<'static, str>;
    fn validate(&self, context: RuleContext<'_>) -> Result<(), String>;
}

Required Methods§

Source

fn name(&self) -> Cow<'static, str>

Source

fn validate(&self, context: RuleContext<'_>) -> Result<(), String>

Validate a field in the context of its full input payload.

§Errors

Returns a user-facing validation message when the field is invalid.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Rule for MaxLength

Source§

impl Rule for MinLength

Source§

impl Rule for Required

Source§

impl Rule for StringRule

Source§

impl<F> Rule for CustomRule<F>
where F: for<'a> Fn(RuleContext<'a>) -> Result<(), String> + Send + Sync + 'static,