blob: e15b3a63004b0dbc8e685e8d79bf8c254d1e32fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
extern crate regex;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate validator_derive;
extern crate validator;
use validator::Validate;
use regex::Regex;
lazy_static! {
static ref RE2: Regex = Regex::new(r"^[a-z]{2}$").unwrap();
}
#[derive(Validate)]
struct Test {
#[validate(regex = "crate::RE2")]
s: String,
}
#[derive(Validate)]
struct TestPath {
#[validate(regex = "crate::RE2")]
s: String,
}
fn main() {}
|