pub struct ConditionalRule {
pub target_field: String,
pub condition: Option<FieldCondition>,
pub validators: Vec<FieldValidator>,
pub error_message: Option<String>,
}Expand description
A conditional validation rule
Fieldsยง
ยงtarget_field: Stringยงcondition: Option<FieldCondition>ยงvalidators: Vec<FieldValidator>ยงerror_message: Option<String>Implementationsยง
Sourceยงimpl ConditionalRule
impl ConditionalRule
Sourcepub fn when(self, condition: FieldCondition) -> Self
pub fn when(self, condition: FieldCondition) -> Self
Set the condition for this rule
Sourcepub fn validate_with(self, validator: FieldValidator) -> Self
pub fn validate_with(self, validator: FieldValidator) -> Self
Add a validator to this rule
Sourcepub fn with_error_message(self, message: String) -> Self
pub fn with_error_message(self, message: String) -> Self
Set the error message for this rule
Sourcepub fn target_field(&self) -> &str
pub fn target_field(&self) -> &str
Get the target field name
Sourcepub fn condition(&self) -> Option<&FieldCondition>
pub fn condition(&self) -> Option<&FieldCondition>
Get the condition for this rule
Sourcepub fn validators(&self) -> &[FieldValidator] โ
pub fn validators(&self) -> &[FieldValidator] โ
Get the validators for this rule
Sourcepub fn error_message(&self) -> Option<&str>
pub fn error_message(&self) -> Option<&str>
Get the error message for this rule
Sourcepub fn has_condition(&self) -> bool
pub fn has_condition(&self) -> bool
Check if this rule has a condition
Sourcepub fn has_validators(&self) -> bool
pub fn has_validators(&self) -> bool
Check if this rule has validators
Trait Implementationsยง
Auto Trait Implementationsยง
impl Freeze for ConditionalRule
impl !RefUnwindSafe for ConditionalRule
impl Send for ConditionalRule
impl Sync for ConditionalRule
impl Unpin for ConditionalRule
impl UnsafeUnpin for ConditionalRule
impl !UnwindSafe for ConditionalRule
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> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSourceยงimpl<T> SerializableKey for T
impl<T> SerializableKey for T
Sourceยงimpl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Sourceยงfn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Borrows the value.
Sourceยงfn into_taken(self) -> T
fn into_taken(self) -> T
Takes the value.