Skip to main content

validate_record_fields

Function validate_record_fields 

Source
pub fn validate_record_fields<'g, 'f, I>(
    graph: &'g SchemaGraph,
    fields: I,
    values: &[SchemaValue],
) -> Result<(), Vec<ValueError>>
where I: Iterator<Item = (&'f str, &'f SchemaType)> + Clone,
Expand description

Validate the field values of a record against a set of named field types defined in graph, without materialising a temporary record SchemaType.

This is the allocation-light counterpart of validating a Record value against SchemaType::record(fields): each (name, body) pair is borrowed from the caller’s schema, so only the field name is cloned (for the error path segment) — never the (potentially large) field SchemaType or its metadata. The produced ValueErrors carry the same .field("name")… ValuePath context as validating the equivalent record type would.

fields and values must be in matching parameter order; a length mismatch is reported as a single ValueError::RecordArityMismatch at the root, exactly as the record-validation path does.