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
//! # RustAPI Validation
//!
//! Validation system for RustAPI framework. Provides declarative validation
//! on structs using the `#[derive(Validate)]` macro.
//!
//! ## Example
//!
//! ```rust,ignore
//! use rustapi_validate::prelude::*;
//! use validator::Validate;
//!
//! #[derive(Validate)]
//! struct CreateUser {
//! #[validate(email)]
//! email: String,
//!
//! #[validate(length(min = 3, max = 50))]
//! username: String,
//!
//! #[validate(range(min = 18, max = 120))]
//! age: u8,
//! }
//! ```
//!
//! ## V2 Validation Engine
//!
//! The v2 module provides a custom validation engine with async support:
//!
//! ```rust,ignore
//! use rustapi_validate::v2::prelude::*;
//!
//! #[derive(Validate)]
//! struct CreateUser {
//! #[validate(email, message = "Invalid email format")]
//! email: String,
//!
//! #[validate(length(min = 3, max = 50))]
//! username: String,
//!
//! #[validate(async_unique(table = "users", column = "email"))]
//! unique_email: String,
//! }
//! ```
//!
//! ## Validation Rules
//!
//! - `email` - Validates email format
//! - `length(min = X, max = Y)` - String length validation
//! - `range(min = X, max = Y)` - Numeric range validation
//! - `regex = "..."` - Regex pattern validation
//! - `url` - URL format validation
//! - `required` - Non-empty string/option validation
//! - `async_unique(table, column)` - Database uniqueness check
//! - `async_exists(table, column)` - Database existence check
//! - `async_api(endpoint)` - External API validation
//!
//! ## Error Format
//!
//! Validation errors return a 422 Unprocessable Entity with JSON:
//!
//! ```json
//! {
//! "error": {
//! "type": "validation_error",
//! "message": "Validation failed",
//! "fields": [
//! {"field": "email", "code": "email", "message": "Invalid email format"},
//! {"field": "age", "code": "range", "message": "Value must be between 18 and 120"}
//! ]
//! }
//! }
//! ```
// Load I18n locales
i18n!;
/// V2 validation engine with async support.
///
/// This module provides a custom validation engine that replaces the external
/// `validator` dependency and adds support for async validation operations.
pub use ;
pub use Validate;
// Re-export the v2 Validate derive macro
pub use Validate as DeriveValidate;
/// Prelude module for validation