pub struct RuleBuilder<T> { /* private fields */ }Expand description
Builder for creating validation rules in a fluent style
Implementations§
Source§impl<T> RuleBuilder<T>
impl<T> RuleBuilder<T>
Sourcepub fn for_property(property_name: impl Into<String>) -> Self
pub fn for_property(property_name: impl Into<String>) -> Self
Create a new rule builder for a property
Sourcepub fn not_empty(self, message: Option<impl Into<String>>) -> Self
pub fn not_empty(self, message: Option<impl Into<String>>) -> Self
Validate that the value is not empty (for strings)
§Arguments
message- Optional custom error message. If not provided, uses default message.
Sourcepub fn not_null(self, message: Option<impl Into<String>>) -> Selfwhere
T: OptionLike,
pub fn not_null(self, message: Option<impl Into<String>>) -> Selfwhere
T: OptionLike,
Validate that the value is not null/empty (for Option types)
§Arguments
message- Optional custom error message. If not provided, uses default message.
Sourcepub fn min_length(
self,
min: usize,
message: Option<impl Into<String> + Clone + 'static>,
) -> Self
pub fn min_length( self, min: usize, message: Option<impl Into<String> + Clone + 'static>, ) -> Self
Validate minimum length
§Arguments
min- Minimum length requiredmessage- Optional custom error message. If not provided, uses default message with the min value.
Sourcepub fn max_length(
self,
max: usize,
message: Option<impl Into<String> + Clone + 'static>,
) -> Self
pub fn max_length( self, max: usize, message: Option<impl Into<String> + Clone + 'static>, ) -> Self
Validate maximum length
§Arguments
max- Maximum length allowedmessage- Optional custom error message. If not provided, uses default message with the max value.
Sourcepub fn length(
self,
min: usize,
max: usize,
min_message: Option<impl Into<String> + Clone + 'static>,
max_message: Option<impl Into<String> + Clone + 'static>,
) -> Self
pub fn length( self, min: usize, max: usize, min_message: Option<impl Into<String> + Clone + 'static>, max_message: Option<impl Into<String> + Clone + 'static>, ) -> Self
Validate length range
§Arguments
min- Minimum length requiredmax- Maximum length allowedmin_message- Optional custom error message for minimum length violationmax_message- Optional custom error message for maximum length violation
Sourcepub fn email(self, message: Option<impl Into<String>>) -> Self
pub fn email(self, message: Option<impl Into<String>>) -> Self
Validate email format
§Arguments
message- Optional custom error message. If not provided, uses default message.
Sourcepub fn greater_than(
self,
min: impl Into<f64> + Copy + 'static,
message: Option<impl Into<String> + Clone + 'static>,
) -> Selfwhere
T: Numeric,
pub fn greater_than(
self,
min: impl Into<f64> + Copy + 'static,
message: Option<impl Into<String> + Clone + 'static>,
) -> Selfwhere
T: Numeric,
Validate that value is greater than a minimum
§Arguments
min- Minimum value (exclusive)message- Optional custom error message. If not provided, uses default message with the min value.
Sourcepub fn greater_than_or_equal(
self,
min: impl Into<f64> + Copy + 'static,
message: Option<impl Into<String> + Clone + 'static>,
) -> Selfwhere
T: Numeric,
pub fn greater_than_or_equal(
self,
min: impl Into<f64> + Copy + 'static,
message: Option<impl Into<String> + Clone + 'static>,
) -> Selfwhere
T: Numeric,
Validate that value is greater than or equal to a minimum
§Arguments
min- Minimum value (inclusive)message- Optional custom error message. If not provided, uses default message with the min value.
Sourcepub fn less_than(
self,
max: impl Into<f64> + Copy + 'static,
message: Option<impl Into<String> + Clone + 'static>,
) -> Selfwhere
T: Numeric,
pub fn less_than(
self,
max: impl Into<f64> + Copy + 'static,
message: Option<impl Into<String> + Clone + 'static>,
) -> Selfwhere
T: Numeric,
Validate that value is less than a maximum
§Arguments
max- Maximum value (exclusive)message- Optional custom error message. If not provided, uses default message with the max value.
Sourcepub fn less_than_or_equal(
self,
max: impl Into<f64> + Copy + 'static,
message: Option<impl Into<String> + Clone + 'static>,
) -> Selfwhere
T: Numeric,
pub fn less_than_or_equal(
self,
max: impl Into<f64> + Copy + 'static,
message: Option<impl Into<String> + Clone + 'static>,
) -> Selfwhere
T: Numeric,
Validate that value is less than or equal to a maximum
§Arguments
max- Maximum value (inclusive)message- Optional custom error message. If not provided, uses default message with the max value.
Sourcepub fn inclusive_between(
self,
min: impl Into<f64> + Copy + 'static,
max: impl Into<f64> + Copy + 'static,
message: Option<impl Into<String> + Clone + 'static>,
) -> Selfwhere
T: Numeric,
pub fn inclusive_between(
self,
min: impl Into<f64> + Copy + 'static,
max: impl Into<f64> + Copy + 'static,
message: Option<impl Into<String> + Clone + 'static>,
) -> Selfwhere
T: Numeric,
Validate that value is within a range (inclusive)
§Arguments
min- Minimum value (inclusive)max- Maximum value (inclusive)message- Optional custom error message. If not provided, uses default message with the min and max values.
Auto Trait Implementations§
impl<T> Freeze for RuleBuilder<T>
impl<T> !RefUnwindSafe for RuleBuilder<T>
impl<T> !Send for RuleBuilder<T>
impl<T> !Sync for RuleBuilder<T>
impl<T> Unpin for RuleBuilder<T>
impl<T> !UnwindSafe for RuleBuilder<T>
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