pub struct ValidationItem {
pub field: String,
pub message: String,
pub code: Option<String>,
}Expand description
A single field-level validation error.
Used within the "errors" extension key to report multiple validation
failures in a structured format suitable for frontend form binding.
§Example
use rust_rfc7807::ValidationItem;
let item = ValidationItem::new("email", "must be a valid email address")
.code("INVALID_EMAIL");
let json = serde_json::to_value(&item).unwrap();
assert_eq!(json["field"], "email");
assert_eq!(json["code"], "INVALID_EMAIL");Fields§
§field: StringThe field path that failed validation (e.g., "email" or "address.zip").
message: StringA human-readable description of the validation failure.
code: Option<String>An optional machine-readable error code for this specific validation failure.
Implementations§
Trait Implementations§
Source§impl Clone for ValidationItem
impl Clone for ValidationItem
Source§fn clone(&self) -> ValidationItem
fn clone(&self) -> ValidationItem
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 ValidationItem
impl Debug for ValidationItem
Source§impl<'de> Deserialize<'de> for ValidationItem
impl<'de> Deserialize<'de> for ValidationItem
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 PartialEq for ValidationItem
impl PartialEq for ValidationItem
Source§impl Serialize for ValidationItem
impl Serialize for ValidationItem
impl Eq for ValidationItem
impl StructuralPartialEq for ValidationItem
Auto Trait Implementations§
impl Freeze for ValidationItem
impl RefUnwindSafe for ValidationItem
impl Send for ValidationItem
impl Sync for ValidationItem
impl Unpin for ValidationItem
impl UnsafeUnpin for ValidationItem
impl UnwindSafe for ValidationItem
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