[][src]Macro vale::rule

rule!() { /* proc-macro */ }

The rule macro is used to create new rules that dictate how a field of the validated entity should be tranformed and validated.

Example

struct MyStruct {
    a: i32,
}

impl vale::Validate for MyStruct {
    #[vale::ruleset]
    fn validate(&mut self) -> vale::Result {
        vale::rule!(self.a == 3, "A was not three!");
        // if the second argument is omitted, a standard error message is returned.
        vale::rule!(self.a % 3 == 0);
    }
}