pub struct FieldErrors { /* private fields */ }Expand description
A refused submission, keyed by the form key each error renders under.
One type for every source: the schema’s own rules
(Schema::validate), a rejected upload, a
failed uniqueness probe, and an app’s
validate_record. The submit handler
merges them without translating, and the form render reads each field’s own
key from the result.
A key the rendered form owns: a control’s own key, or a
Repeater group’s label. A key no slot owns has nowhere
to render, and the submit handler refuses it as a declaration error rather
than writing past it.
Implementations§
Source§impl FieldErrors
impl FieldErrors
Sourcepub fn add(&mut self, key: impl Into<String>, message: impl Into<String>)
pub fn add(&mut self, key: impl Into<String>, message: impl Into<String>)
Refuse key with message.
Sourcepub fn add_required(
&mut self,
key: impl Into<String>,
message: impl Into<String>,
)
pub fn add_required( &mut self, key: impl Into<String>, message: impl Into<String>, )
Refuse key as unanswered, with the message its control renders.
Sourcepub fn push(&mut self, error: FieldError)
pub fn push(&mut self, error: FieldError)
Refuse error’s key with error, keeping the error’s own kind.
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Whether any error renders under key.
Sourcepub fn first(&self, key: &str) -> Option<&FieldError>
pub fn first(&self, key: &str) -> Option<&FieldError>
The error key renders: the first one added, like the render’s own
first-message slot.
Sourcepub fn iter(&self) -> impl Iterator<Item = &FieldError>
pub fn iter(&self) -> impl Iterator<Item = &FieldError>
Every error, in the order it was added.