pub struct NumericValidator {
pub min: Option<f64>,
pub max: Option<f64>,
pub integer_only: bool,
pub positive_only: bool,
pub negative_only: bool,
pub message: Option<String>,
}
Expand description
Validator for numeric constraints
Fields§
§min: Option<f64>
Minimum value (inclusive)
max: Option<f64>
Maximum value (inclusive)
integer_only: bool
Allow only integers (no decimals)
positive_only: bool
Allow only positive numbers (> 0)
negative_only: bool
Allow only negative numbers (< 0)
message: Option<String>
Custom error message
Implementations§
Source§impl NumericValidator
impl NumericValidator
Sourcepub fn integer_only(self, integer_only: bool) -> Self
pub fn integer_only(self, integer_only: bool) -> Self
Require integer values only (no decimals)
Sourcepub fn positive_only(self, positive_only: bool) -> Self
pub fn positive_only(self, positive_only: bool) -> Self
Allow only positive numbers (> 0)
Sourcepub fn negative_only(self, negative_only: bool) -> Self
pub fn negative_only(self, negative_only: bool) -> Self
Allow only negative numbers (< 0)
Trait Implementations§
Source§impl Clone for NumericValidator
impl Clone for NumericValidator
Source§fn clone(&self) -> NumericValidator
fn clone(&self) -> NumericValidator
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 NumericValidator
impl Debug for NumericValidator
Source§impl Default for NumericValidator
impl Default for NumericValidator
Source§impl ValidationRule for NumericValidator
impl ValidationRule for NumericValidator
Source§fn validate<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
value: &'life1 Value,
field: &'life2 str,
) -> Pin<Box<dyn Future<Output = ValidationResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn validate<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
value: &'life1 Value,
field: &'life2 str,
) -> Pin<Box<dyn Future<Output = ValidationResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Validate a single value
Source§fn parameters(&self) -> Option<Value>
fn parameters(&self) -> Option<Value>
Get validation rule parameters/configuration as JSON
Auto Trait Implementations§
impl Freeze for NumericValidator
impl RefUnwindSafe for NumericValidator
impl Send for NumericValidator
impl Sync for NumericValidator
impl Unpin for NumericValidator
impl UnwindSafe for NumericValidator
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