pub enum ValidationRule {
MinLength {
field_name: String,
min: usize,
error_message: String,
},
MaxLength {
field_name: String,
max: usize,
error_message: String,
},
Pattern {
field_name: String,
pattern: String,
error_message: String,
},
MinValue {
field_name: String,
min: f64,
error_message: String,
},
MaxValue {
field_name: String,
max: f64,
error_message: String,
},
Email {
field_name: String,
error_message: String,
},
Url {
field_name: String,
error_message: String,
},
FieldsEqual {
field_names: Vec<String>,
error_message: String,
target_field: Option<String>,
},
DateRange {
start_field: String,
end_field: String,
error_message: String,
target_field: Option<String>,
},
NumericRange {
min_field: String,
max_field: String,
error_message: String,
target_field: Option<String>,
},
ValidatorRef {
field_name: String,
validator_id: String,
params: Value,
error_message: String,
},
}Expand description
Validation rule types for client-side validation (Phase 2-A)
These rules enable client-side validation for better UX, while server-side validation remains mandatory for security.
§Security Note
Client-side validation is for UX enhancement only and MUST NOT be relied upon for security. Server-side validation is always required.
§Design Principle
All validation rules are declarative and type-safe. We do NOT use JavaScript expressions to prevent arbitrary code execution vulnerabilities. Instead, each rule type has specific parameters that are validated in Rust.
Variants§
MinLength
Minimum length validation for string fields
Fields
MaxLength
Maximum length validation for string fields
Fields
Pattern
Regex pattern validation for string fields
Fields
MinValue
Minimum value validation for numeric fields
Fields
MaxValue
Maximum value validation for numeric fields
Fields
Email format validation
Fields
Url
URL format validation
Fields
FieldsEqual
Cross-field equality validation (e.g., password confirmation)
Fields
DateRange
Date range validation (end_date >= start_date)
Fields
NumericRange
Numeric range validation (max >= min)
Fields
ValidatorRef
Reference to reinhardt-validators Validator
Trait Implementations§
Source§impl Clone for ValidationRule
impl Clone for ValidationRule
Source§fn clone(&self) -> ValidationRule
fn clone(&self) -> ValidationRule
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more