pub struct Rules { /* private fields */ }
Expand description
Collection of validation rules for a specific field or request
Implementations§
Source§impl Rules
impl Rules
Sourcepub fn field<R>(self, field: impl Into<String>, rule: R) -> Selfwhere
R: ValidationRule + 'static,
pub fn field<R>(self, field: impl Into<String>, rule: R) -> Selfwhere
R: ValidationRule + 'static,
Add a validation rule for a specific field
Sourcepub fn field_rules<R>(self, field: impl Into<String>, rules: Vec<R>) -> Selfwhere
R: ValidationRule + 'static,
pub fn field_rules<R>(self, field: impl Into<String>, rules: Vec<R>) -> Selfwhere
R: ValidationRule + 'static,
Add multiple validation rules for a specific field
Sourcepub fn request<R>(self, rule: R) -> Selfwhere
R: ValidationRule + 'static,
pub fn request<R>(self, rule: R) -> Selfwhere
R: ValidationRule + 'static,
Add a request-level validation rule (cross-field validation)
Sourcepub fn get_field_rules(
&self,
field: &str,
) -> Option<&Vec<Arc<dyn ValidationRule>>>
pub fn get_field_rules( &self, field: &str, ) -> Option<&Vec<Arc<dyn ValidationRule>>>
Get rules for a specific field
Sourcepub fn get_request_rules(&self) -> &Vec<Arc<dyn ValidationRule>>
pub fn get_request_rules(&self) -> &Vec<Arc<dyn ValidationRule>>
Get all request-level rules
Sourcepub fn field_rule_count(&self) -> usize
pub fn field_rule_count(&self) -> usize
Get the number of field rules
Sourcepub fn request_rule_count(&self) -> usize
pub fn request_rule_count(&self) -> usize
Get the number of request rules
Sourcepub fn get_validated_fields(&self) -> Vec<&String>
pub fn get_validated_fields(&self) -> Vec<&String>
Get all field names that have validation rules
Trait Implementations§
Source§impl ValidateField for Rules
impl ValidateField for Rules
Source§fn validate_field<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
field: &'life1 str,
value: &'life2 Value,
) -> Pin<Box<dyn Future<Output = ValidationResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn validate_field<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
field: &'life1 str,
value: &'life2 Value,
) -> 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 field value
Source§impl ValidateRequest for Rules
impl ValidateRequest for Rules
Auto Trait Implementations§
impl Freeze for Rules
impl !RefUnwindSafe for Rules
impl Send for Rules
impl Sync for Rules
impl Unpin for Rules
impl !UnwindSafe for Rules
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CreateValidationError for T
impl<T> CreateValidationError for T
fn validation_error(field: &str, message: &str) -> ValidationError
fn validation_error_with_code( field: &str, message: &str, code: &str, ) -> ValidationError
Source§impl<T> Validate for T
impl<T> Validate for T
Source§fn validate<'life0, 'life1, 'async_trait>(
&'life0 self,
data: &'life1 HashMap<String, Value>,
) -> Pin<Box<dyn Future<Output = ValidationResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn validate<'life0, 'life1, 'async_trait>(
&'life0 self,
data: &'life1 HashMap<String, Value>,
) -> Pin<Box<dyn Future<Output = ValidationResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Validate both individual fields and the entire request