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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! Macro implementations for WebForms
extern crate proc_macro;
use crateTokenStream;
use syn;
/// Derives the ValidateForm trait from for a given struct
///
/// Different types have different available validate tags. Using an
/// invalid attribute tag on an type (e.g., max_length on an int type)
/// will cause the compiler to panic.
///
/// Type: String
/// * `min_length` - Minimum length of the string
/// * `max_length` - Maximum length of the string
/// * `regex` - Input must match the supplied regular expression
/// * `email` - Special regex to validate an email address
///
/// Using either the `regex` or `email` attributes requires your crate
/// to depend on both the regex and lazy_static crates. lazy_static is
/// required to minimize the number of times a given regex is compiled
///
/// Type: Integer
/// * `min_value` - Minimum value of this int
/// * `max_value` - Maxium value of this int
///
/// # Example
///
/// ```compile_fail
/// #[derive(ValidateForm)]
/// struct LoginForm {
/// /// Username must between 4 and 16 characters
/// #[validate(min_length = 4)]
/// #[validate(max_length = 16)]
/// pub username: String,
///
/// ///Email must conform to the email regex provided
/// #[validate(email)]
/// pub email: String,
/// }
/// ```