skp_validator/
lib.rs

1//! # skp-validator
2//!
3//! The most advanced, flexible and modular validation library for Rust.
4//!
5//! ## Features
6//!
7//! - **Declarative Validation**: Use derive macros with powerful attributes
8//! - **30+ Built-in Validators**: email, url, ip, uuid, phone, credit_card, etc.
9//! - **Nested Validation**: Automatic validation of nested structs
10//! - **Collection Validation**: Dive into Vec, HashMap, Option
11//! - **Field Dependencies**: Conditional validation based on other fields
12//! - **Field Transformations**: uppercase, lowercase, trim
13//! - **Structured Errors**: Nested, JSON-serializable error format
14//! - **Runtime JSON Validation**: Validate JSON without deserialization
15//! - **i18n Support**: Localized error messages
16//! - **Framework Adapters**: Axum, Actix integration
17//!
18//! ## Quick Start
19//!
20//! ```rust,ignore
21//! use skp_validator::Validate;
22//!
23//! #[derive(Validate)]
24//! struct User {
25//!     #[validate(required, length(min = 3, max = 50))]
26//!     name: String,
27//!
28//!     #[validate(required, email)]
29//!     email: String,
30//!
31//!     #[validate(range(min = 18, max = 120))]
32//!     age: Option<u32>,
33//!
34//!     #[validate(nested)]
35//!     address: Address,
36//!
37//!     #[validate(dive, length(min = 1, max = 20))]
38//!     tags: Vec<String>,
39//! }
40//!
41//! let user = User { /* ... */ };
42//! match user.validate() {
43//!     Ok(()) => println!("Valid!"),
44//!     Err(errors) => println!("Errors: {}", errors),
45//! }
46//! ```
47
48// Re-export core types
49pub use skp_validator_core::*;
50
51// Re-export rules
52pub use skp_validator_rules as rules;
53
54// Re-export derive macro
55#[cfg(feature = "derive")]
56pub use skp_validator_derive::Validate;
57
58/// Prelude for convenient imports
59pub mod prelude {
60    pub use skp_validator_core::prelude::*;
61
62    #[cfg(feature = "derive")]
63    pub use skp_validator_derive::Validate;
64}