aboutsummaryrefslogtreecommitdiffstats
path: root/validator_derive/tests/run-pass/regex.rs
blob: dcac3c0d088a240fb2bb75c02a13fc2494c20e29 (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 = "RE2")]
    s: String,
}

#[derive(Validate)]
struct TestPath {
    #[validate(regex = "::RE2")]
    s: String,
}

fn main() {}