pub struct OptionConstraint {
pub min: Option<i64>,
pub max: Option<i64>,
pub min_length: Option<usize>,
pub max_length: Option<usize>,
}Expand description
Constraints for option value validation.
These constraints are checked when setting option values. Not all constraints apply to all value types.
Fields§
§min: Option<i64>For Integer: minimum value (inclusive).
max: Option<i64>For Integer: maximum value (inclusive).
min_length: Option<usize>For String: minimum length.
max_length: Option<usize>For String: maximum length.
Implementations§
Source§impl OptionConstraint
impl OptionConstraint
Sourcepub const fn range(min: i64, max: i64) -> Self
pub const fn range(min: i64, max: i64) -> Self
Create a constraint with integer range (inclusive).
Sourcepub const fn string_length(min_length: usize, max_length: usize) -> Self
pub const fn string_length(min_length: usize, max_length: usize) -> Self
Create a constraint with string length range.
Sourcepub fn validate(&self, value: &OptionValue) -> Result<(), ConstraintError>
pub fn validate(&self, value: &OptionValue) -> Result<(), ConstraintError>
Validate a value against this constraint.
§Errors
Returns ConstraintError if the value violates the constraint.
Trait Implementations§
Source§impl Clone for OptionConstraint
impl Clone for OptionConstraint
Source§fn clone(&self) -> OptionConstraint
fn clone(&self) -> OptionConstraint
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 OptionConstraint
impl Debug for OptionConstraint
Source§impl Default for OptionConstraint
impl Default for OptionConstraint
Source§fn default() -> OptionConstraint
fn default() -> OptionConstraint
Returns the “default value” for a type. Read more
Source§impl PartialEq for OptionConstraint
impl PartialEq for OptionConstraint
impl Eq for OptionConstraint
impl StructuralPartialEq for OptionConstraint
Auto Trait Implementations§
impl Freeze for OptionConstraint
impl RefUnwindSafe for OptionConstraint
impl Send for OptionConstraint
impl Sync for OptionConstraint
impl Unpin for OptionConstraint
impl UnsafeUnpin for OptionConstraint
impl UnwindSafe for OptionConstraint
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