| 256 | |
| 257 | impl FromDirective for Box<dyn Validator> { |
| 258 | fn from_directive(directive: Directive) -> Result<Self, String> |
| 259 | where |
| 260 | Self: Sized, |
| 261 | { |
| 262 | match directive.name.as_str() { |
| 263 | "string" => Ok(Box::new(StringValidator::from_directive(directive)?)), |
| 264 | "number" => Ok(Box::new(NumberValidator::from_directive(directive)?)), |
| 265 | "in" => Ok(Box::new(InValidator::from_directive(directive)?)), |
| 266 | "any" => Ok(Box::new(AnyValidator::from_directive(directive)?)), |
| 267 | "not" => Ok(Box::new(NotValidator::from_directive(directive)?)), |
| 268 | "date" => Ok(Box::new(DateValidator::from_directive(directive)?)), |
| 269 | "array" => Ok(Box::new(AnyValidator::from_directive(directive)?)), |
| 270 | "regex" => Ok(Box::new(RegexValidator::from_directive(directive)?)), |
| 271 | v => Err(format!("Invalid validators: @{}", v)), |
| 272 | } |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | impl FromDirective for StringValidator { |