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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//! Request validation for Ferro framework.
//!
//! Provides Laravel-inspired validation with declarative rules.
//!
//! ## Flash round-trip (Phase 137)
//!
//! On validation failure a POST handler can redirect back and preserve both
//! errors and old form input in the session flash:
//!
//! ```rust,ignore
//! use ferro_rs::validation::{Validator, rules::*};
//! use ferro_rs::rules;
//!
//! // POST handler
//! let data = req.input::<serde_json::Value>().await?;
//! if let Err(e) = Validator::new(&data)
//! .rules("name", rules![required()])
//! .validate()
//! {
//! let referer = req.header("Referer");
//! return e.with_old_input(&data).redirect_back(referer);
//! }
//!
//! // GET handler — repopulate form fields
//! InputProps {
//! default_value: req.old("name"),
//! error: req.validation_error("name"),
//! ..Default::default()
//! }
//! ```
//!
//! # Example
//!
//! ```rust,ignore
//! use ferro_rs::validation::{Validator, rules};
//!
//! let data = serde_json::json!({
//! "email": "user@example.com",
//! "password": "secret123",
//! "age": 25
//! });
//!
//! let validator = Validator::new(&data)
//! .rules("email", rules![required, email])
//! .rules("password", rules![required, min(8)])
//! .rules("age", rules![required, integer, min(18)]);
//!
//! if let Err(errors) = validator.validate() {
//! println!("Validation failed: {:?}", errors);
//! }
//! ```
pub use translate_validation;
pub use ;
pub use ValidationError;
pub use Rule;
pub use *;
pub use Validatable;
pub use ;
/// Macro for creating a vector of boxed validation rules.
///
/// This macro boxes each rule, allowing different rule types to be stored
/// together in a single vector.
///
/// # Example
///
/// ```rust,ignore
/// use ferro_rs::validation::{Validator, rules::*};
/// use ferro_rs::rules;
///
/// let validator = Validator::new(&data)
/// .rules("email", rules![required(), email()])
/// .rules("name", rules![required(), string(), max(255)]);
/// ```