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
/*******************************************************************************
*
* Copyright (c) 2025 - 2026.
* Haixing Hu, Qubit Co. Ltd.
*
* All rights reserved.
*
******************************************************************************/
//! # Argument Validation
//!
//! Provides argument validation functionality similar to Java's `Argument` class, but with a design more suitable for Rust conventions.
//!
//! # Module Organization
//!
//! - `error`: Error type definitions
//! - `numeric`: Numeric argument validation
//! - `string`: String argument validation
//! - `collection`: Collection argument validation
//! - `option`: Option argument validation
//! - `condition`: Condition and state validation
//!
//! # Design Philosophy
//!
//! This module uses Rust's trait extension pattern to provide validation methods for various types.
//! Compared to Java's static methods, this approach is more idiomatic in Rust and supports method chaining.
//!
//! # Usage Examples
//!
//! ```rust,ignore
//! use common_rs::lang::argument::{
//! NumericArgument, StringArgument, CollectionArgument, ArgumentResult
//! };
//! use regex::Regex;
//!
//! fn process_user_input(
//! age: i32,
//! username: &str,
//! tags: &[String],
//! ) -> ArgumentResult<()> {
//! // Numeric validation
//! let age = age.require_in_closed_range("age", 0, 150)?;
//!
//! // String validation (regex + chaining)
//! let username_pattern = Regex::new(r"^[a-zA-Z][a-zA-Z0-9_]{2,19}$").unwrap();
//! let username = username
//! .require_non_blank("username")?
//! .require_match("username", &username_pattern)?;
//!
//! // Collection validation (chaining)
//! let tags = tags
//! .require_non_empty("tags")?
//! .require_length_at_most("tags", 10)?;
//!
//! println!("Age: {}, Username: {}, Tag count: {}", age, username, tags.len());
//! Ok(())
//! }
//! ```
//!
//! # Author
//!
//! Haixing Hu
// Re-export main types and traits
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use StringArgument;