Macro adequate::validate [−][src]
macro_rules! validate { ( $( $n:expr => $v:expr => [ $( $c:expr ),* ] ),* ) => { ... }; }
Expand description
validate! macro validates given fields and its inputs.
Examples
let text = "lorem ipsum dolor sit amet".to_string(); let result = validate! { "name" => text => [length::max(9)] }; assert!(result.is_err()); let Error(out) = result.unwrap_err(); assert_eq!(out, vec![ Feedback { field: "name".to_string(), messages: vec![ Message { text: "Must not contain more characters than {0}" .to_string(), args: vec!["9".to_string()] } ] } ]); let result = validate! { "name" => text => [length::max(64)], "description" => text => [length::max(255)] }; assert!(result.is_ok());