pub enum ValidationRule {
MustExist {
must_exist: bool,
},
Extensions {
extensions: Vec<String>,
},
Range {
min: Option<f64>,
max: Option<f64>,
},
}Expand description
Validation rules for arguments and options
These rules are applied after type parsing to enforce additional constraints on values.
§Variants
MustExist: For paths, require that the file/directory existsExtensions: For paths, restrict to specific file extensionsRange: For numbers, enforce min/max bounds
§Serialization
Rules use untagged enum serialization:
# MustExist
- must_exist: true
# Extensions
- extensions: [yaml, yml, json]
# Range
- min: 0.0
max: 100.0Variants§
MustExist
Require that a path exists on the file system
Extensions
Restrict file extensions (for path arguments)
Extensions should be specified without the leading dot.
Example: ["yaml", "yml"] matches “config.yaml” and “data.yml”
Range
Enforce numeric range constraints
Either or both bounds can be specified:
min: Some(0.0), max: None→ x ≥ 0min: None, max: Some(100.0)→ x ≤ 100min: Some(0.0), max: Some(100.0)→ 0 ≤ x ≤ 100
Trait Implementations§
Source§impl Clone for ValidationRule
impl Clone for ValidationRule
Source§fn clone(&self) -> ValidationRule
fn clone(&self) -> ValidationRule
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ValidationRule
impl Debug for ValidationRule
Source§impl<'de> Deserialize<'de> for ValidationRule
impl<'de> Deserialize<'de> for ValidationRule
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for ValidationRule
impl PartialEq for ValidationRule
Source§impl Serialize for ValidationRule
impl Serialize for ValidationRule
impl StructuralPartialEq for ValidationRule
Auto Trait Implementations§
impl Freeze for ValidationRule
impl RefUnwindSafe for ValidationRule
impl Send for ValidationRule
impl Sync for ValidationRule
impl Unpin for ValidationRule
impl UnwindSafe for ValidationRule
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more