Skip to main content

read_attribute

Function read_attribute 

Source
pub fn read_attribute<T: Attribute>(
    document: &Value,
    name: &str,
    ctx: &Context,
) -> Result<T, JsonApiError>
Available on crate features http and validation only.
Expand description

Read one attribute out of a validated document.

Used by resource!. The schema has already checked the member’s type, so a failure here means the two disagree — a hand-written Attribute whose schema is looser than its read — and it is reported as a 422 pointing at the member rather than quietly defaulted.