pub struct CustomResultRule<T: ?Sized, F>{
pub rule_name: String,
pub validator: Arc<F>,
/* private fields */
}Expand description
Custom validation with result - allows returning detailed errors.
Fields§
§rule_name: StringRule name for error reporting
validator: Arc<F>The validation function
Implementations§
Source§impl<T: ?Sized, F> CustomResultRule<T, F>
impl<T: ?Sized, F> CustomResultRule<T, F>
Trait Implementations§
Source§impl<T: ?Sized, F> Clone for CustomResultRule<T, F>
impl<T: ?Sized, F> Clone for CustomResultRule<T, F>
Source§impl<T: ?Sized, F> Debug for CustomResultRule<T, F>
impl<T: ?Sized, F> Debug for CustomResultRule<T, F>
Source§impl<T: ?Sized, F> Rule<T> for CustomResultRule<T, F>
impl<T: ?Sized, F> Rule<T> for CustomResultRule<T, F>
Source§fn validate(&self, value: &T, ctx: &ValidationContext) -> ValidationResult<()>
fn validate(&self, value: &T, ctx: &ValidationContext) -> ValidationResult<()>
Validate the value.
Source§fn default_message(&self) -> String
fn default_message(&self) -> String
Get the default error message.
Source§fn validate_at(
&self,
value: &T,
path: &FieldPath,
ctx: &ValidationContext,
) -> Result<(), ValidationErrors>
fn validate_at( &self, value: &T, path: &FieldPath, ctx: &ValidationContext, ) -> Result<(), ValidationErrors>
Validate the value with a field path for error reporting.
Source§fn error_code(&self) -> String
fn error_code(&self) -> String
Get the error code.
Source§fn is_transform(&self) -> bool
fn is_transform(&self) -> bool
Check if this rule is a transformation (not validation).
Auto Trait Implementations§
impl<T, F> Freeze for CustomResultRule<T, F>where
T: ?Sized,
impl<T, F> RefUnwindSafe for CustomResultRule<T, F>where
F: RefUnwindSafe,
T: ?Sized,
impl<T, F> Send for CustomResultRule<T, F>where
T: ?Sized,
impl<T, F> Sync for CustomResultRule<T, F>where
T: ?Sized,
impl<T, F> Unpin for CustomResultRule<T, F>where
T: ?Sized,
impl<T, F> UnwindSafe for CustomResultRule<T, F>where
F: RefUnwindSafe,
T: ?Sized,
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