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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//! # Catfive
//!
//! **Catfive** is a category-5, fluent, zero-dependency schema and form validation library for Rust.
//! Inspired by developer-friendly validation libraries, it lets you construct composable validation
//! rules without procedural attribute macros (`#[derive(...)]`).
//!
//! ## Key Features
//! - **Macro-free**: Clean, functional, and composable builder API.
//! - **Zero dependencies**: Core validation operates entirely on `std`.
//! - **Cloneable Validators**: All validators implement `Clone` for easy template reuse.
//! - **Detailed errors & Custom Messages**: Rules support `println!`-style placeholders (e.g. `{char}`, `{min}`, `{count}`) or closures.
//! - **Form and Schema support**: Validate untyped form payloads as well as strongly-typed Rust structs with nested schemas and refinements.
//! - **Collections & Lists**: Validate arrays and vectors with `list(...)`.
//! - **Optional Serde**: Enable the `serde` Cargo feature to serialize validation errors to JSON for REST APIs.
//! - **Optional Regex**: Enable the `regex` Cargo feature for arbitrary pattern matching.
pub
// Re-exports of primary types
pub use ;
pub use ;
pub use ListValidator;
pub use NumberValidator;
pub use Schema;
pub use StringValidator;
pub use Validator;
/// Creates a new fluent string validator.
///
/// # Example
/// ```rust
/// use catfive::string;
///
/// let name_val = string().min(3).max(20).block(";@#$&");
/// ```
/// Creates a new fluent numeric validator for any compatible number type.
///
/// # Example
/// ```rust
/// use catfive::number;
///
/// let age_val = number::<u8>().min(18).max(120);
/// ```
/// Creates a new fluent list/array validator for collections of items.
///
/// # Example
/// ```rust
/// use catfive::{list, string, Validator};
///
/// let tags_val = list::<&str, _>(string().min(2)).min_items(1).max_items(5);
/// let tags = vec!["rust", "actix"];
/// assert!(tags_val.validate(&tags).is_ok());
/// ```
/// Creates a new form validator for key-value payloads.
///
/// # Example
/// ```rust
/// use catfive::{form, string};
///
/// let contact_form = form()
/// .field("username", string().min(3).block(";@#$&"))
/// .field("email", string().email());
/// ```
/// Creates a new strongly-typed schema validator for struct `T`.
///
/// # Example
/// ```rust
/// use catfive::{schema, string};
///
/// struct User {
/// username: String,
/// }
///
/// let user_schema = schema::<User>()
/// .field("username", |u| &u.username, string().min(3).block(";@#$&"));
/// ```
/// Convenient prelude module to import all essential traits and constructors.