pub struct VldServerError {
pub message: String,
pub fields: Vec<FieldError>,
}Expand description
Structured validation error for Dioxus server functions.
Serializable and deserializable — can be transmitted from server to client
as part of a ServerFnError message or custom error type.
§With ServerFnError
ⓘ
#[server]
async fn my_fn(name: String) -> Result<(), ServerFnError> {
vld_dioxus::validate_args! {
name => vld::string().min(2),
}.map_err(|e| ServerFnError::new(e.to_string()))?;
Ok(())
}§With custom error type
ⓘ
#[derive(Debug, Clone, Serialize, Deserialize)]
enum AppError {
Validation(VldServerError),
Server(String),
}
impl FromServerFnError for AppError { /* ... */ }
#[server]
async fn my_fn(name: String) -> Result<(), AppError> {
vld_dioxus::validate_args! {
name => vld::string().min(2),
}.map_err(AppError::Validation)?;
Ok(())
}Fields§
§message: StringSummary message.
fields: Vec<FieldError>Per-field validation errors.
Implementations§
Source§impl VldServerError
impl VldServerError
Sourcepub fn validation(fields: Vec<FieldError>) -> Self
pub fn validation(fields: Vec<FieldError>) -> Self
Create a validation error from a list of field errors.
Sourcepub fn field_error(&self, field: &str) -> Option<&str>
pub fn field_error(&self, field: &str) -> Option<&str>
Get the error message for a specific field.
Sourcepub fn field_errors(&self, field: &str) -> Vec<&str>
pub fn field_errors(&self, field: &str) -> Vec<&str>
Get all error messages for a specific field.
Sourcepub fn has_field_error(&self, field: &str) -> bool
pub fn has_field_error(&self, field: &str) -> bool
Check if a specific field has errors.
Sourcepub fn error_fields(&self) -> Vec<&str>
pub fn error_fields(&self) -> Vec<&str>
List all field names that have errors.
Trait Implementations§
Source§impl Clone for VldServerError
impl Clone for VldServerError
Source§fn clone(&self) -> VldServerError
fn clone(&self) -> VldServerError
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for VldServerError
impl Debug for VldServerError
Source§impl<'de> Deserialize<'de> for VldServerError
impl<'de> Deserialize<'de> for VldServerError
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 Display for VldServerError
impl Display for VldServerError
Source§impl Error for VldServerError
impl Error for VldServerError
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()
Source§impl From<VldError> for VldServerError
impl From<VldError> for VldServerError
Source§impl PartialEq for VldServerError
impl PartialEq for VldServerError
Source§impl Serialize for VldServerError
impl Serialize for VldServerError
impl StructuralPartialEq for VldServerError
Auto Trait Implementations§
impl Freeze for VldServerError
impl RefUnwindSafe for VldServerError
impl Send for VldServerError
impl Sync for VldServerError
impl Unpin for VldServerError
impl UnsafeUnpin for VldServerError
impl UnwindSafe for VldServerError
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