pub enum ValidationError {
ExtractionError {
message: String,
is_htmx: bool,
},
ValidationError {
errors: ValidationErrors,
is_htmx: bool,
},
}Expand description
Error type returned by ValidatedForm and ValidatedJson extractors.
Automatically renders HTMX-friendly HTML error components for HTMX requests,
or standard JSON 422/400 responses for REST clients.
HTMX 1.x and 2.x swap only successful responses by default, so an HTMX
request (HX-Request: true) receives the fragment with 200 OK and the
X-Rullst-Validation-Status header set to the 400 or 422 a REST client
would receive. htmx swaps it into the request’s hx-target with its
hx-swap; client scripts can read that header to tell a validation failure
from success.
Every message, field name and validator message is HTML-escaped before it is
placed in the HTMX fragment. The built-in extractors never copy the
deserializer’s error text (which can echo request input) into
ValidationError::ExtractionError; they use a fixed message chosen from the
rejection’s status and log the detail server-side at debug level on the
rullst::validation target.
Variants§
ExtractionError
A deserialization error occurred before validation could run (e.g. malformed JSON body).
Fields
ValidationError
The payload was extracted successfully but failed validator::Validate constraints.
Fields
errors: ValidationErrorsThe set of field-level validation errors returned by the validator crate.
Trait Implementations§
Source§impl Debug for ValidationError
impl Debug for ValidationError
Source§impl Display for ValidationError
impl Display for ValidationError
Source§impl Error for ValidationError
impl Error for ValidationError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()