pub struct RuleError {
pub code: String,
pub message: String,
pub params: HashMap<String, Value>,
}Expand description
Error from a single validation rule.
Fields§
§code: StringThe validation rule code (e.g., “email”, “length”, “range”)
message: StringHuman-readable error message
params: HashMap<String, Value>Optional parameters for message interpolation
Implementations§
Source§impl RuleError
impl RuleError
Sourcepub fn new(code: impl Into<String>, message: impl Into<String>) -> Self
pub fn new(code: impl Into<String>, message: impl Into<String>) -> Self
Create a new rule error.
Sourcepub fn with_params(
code: impl Into<String>,
message: impl Into<String>,
params: HashMap<String, Value>,
) -> Self
pub fn with_params( code: impl Into<String>, message: impl Into<String>, params: HashMap<String, Value>, ) -> Self
Create a rule error with parameters.
Sourcepub fn param(self, key: impl Into<String>, value: impl Serialize) -> Self
pub fn param(self, key: impl Into<String>, value: impl Serialize) -> Self
Add a parameter to the error.
Sourcepub fn interpolate_message(&self) -> String
pub fn interpolate_message(&self) -> String
Interpolate parameters into the message.
Replaces {param_name} placeholders with actual values.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for RuleError
impl<'de> Deserialize<'de> for RuleError
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Error for RuleError
impl Error for RuleError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
impl StructuralPartialEq for RuleError
Auto Trait Implementations§
impl Freeze for RuleError
impl RefUnwindSafe for RuleError
impl Send for RuleError
impl Sync for RuleError
impl Unpin for RuleError
impl UnwindSafe for RuleError
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> ValidateIp for Twhere
T: ToString,
impl<T> ValidateIp for Twhere
T: ToString,
Source§fn validate_ipv4(&self) -> bool
fn validate_ipv4(&self) -> bool
Validates whether the given string is an IP V4
Source§fn validate_ipv6(&self) -> bool
fn validate_ipv6(&self) -> bool
Validates whether the given string is an IP V6
Source§fn validate_ip(&self) -> bool
fn validate_ip(&self) -> bool
Validates whether the given string is an IP