Skip to main content

merge_field_validation_errors

Function merge_field_validation_errors 

Source
pub fn merge_field_validation_errors(
    target: &mut ValidationErrors,
    field: &str,
    nested: &ValidationErrors,
)
Expand description

Records a field validator’s violations under the field it was declared on.

A field validator is handed the value alone and cannot see the public name of the field it is checking, yet the obvious way to write one is to name that field anyway. Prefixing unconditionally, the way merge_validation_errors does for a nested model, turns that into published_at.published_at.

A violation is therefore taken to be about the field itself when its path is empty or is the field, and to be a path inside the value otherwise.