Skip to main content

FieldErrors

Struct FieldErrors 

Source
pub struct FieldErrors<F = String>
where F: FormFields,
{ /* private fields */ }
Expand description

A refused submission, keyed by the form whose fields it names.

Resource::validate_record answers a FieldErrors<UserForm>, keyed by its record form, so an error always names a field the form renders; one on an embedded value renders under its first control. An error picks its field off the form’s keys:

use tablo_core::FieldErrors;

fn validate(form: &UserForm) -> FieldErrors<UserForm> {
    let mut errors = FieldErrors::<UserForm>::new();
    if form.age < 0 {
        errors.add(|f| f.age, "Age must be zero or more");
    }
    errors
}

The panel keys every error by the form key it renders under (FieldErrors, keyed by String), and Source::form reads them back when a schema renders.

Implementations§

Source§

impl<F> FieldErrors<F>
where F: FormFields,

Source

pub fn new() -> FieldErrors<F>

No errors.

Source

pub fn add( &mut self, pick: impl FnOnce(<F as FormFields>::Keys) -> <F as FormFields>::Field, message: impl Into<Text>, )

Refuse the field pick picks off the form’s keys with message: errors.add(|f| f.age, "Age must be zero or more").

Source

pub fn add_field( &mut self, field: impl Into<<F as FormFields>::Field>, message: impl Into<Text>, )

Refuse field with message, the field named directly: the panel’s own errors name a form key, errors.add_field("email", ..).

Source

pub fn push(&mut self, error: FieldError<<F as FormFields>::Field>)

Refuse error’s key with error.

Source

pub fn is_empty(&self) -> bool

Whether nothing was refused.

Source

pub fn iter( &self, ) -> impl Iterator<Item = &FieldError<<F as FormFields>::Field>>

Every error, in the order it was added.

Source

pub fn extend(&mut self, other: FieldErrors<F>)

Append other’s errors after these.

Source§

impl FieldErrors

Source

pub fn contains_key(&self, key: &str) -> bool

Whether any error renders under key.

Source

pub fn first(&self, key: &str) -> Option<&FieldError>

The error key renders: the first one added.

Trait Implementations§

Source§

impl<F> Clone for FieldErrors<F>
where F: FormFields, <F as FormFields>::Field: Clone,

Source§

fn clone(&self) -> FieldErrors<F>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F> Debug for FieldErrors<F>
where F: FormFields, <F as FormFields>::Field: Debug,

Source§

fn fmt(&self, __f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<F> Default for FieldErrors<F>
where F: FormFields,

Source§

fn default() -> FieldErrors<F>

Returns the “default value” for a type. Read more
Source§

impl<F> From<FieldErrors<F>> for WriteError<F>
where F: FormFields,

Source§

fn from(errors: FieldErrors<F>) -> WriteError<F>

Converts to this type from the input type.
Source§

impl<F> IntoIterator for FieldErrors<F>
where F: FormFields,

Source§

type Item = FieldError<<F as FormFields>::Field>

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<FieldError<<F as FormFields>::Field>>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> <FieldErrors<F> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<F> Freeze for FieldErrors<F>

§

impl<F> RefUnwindSafe for FieldErrors<F>

§

impl<F> Send for FieldErrors<F>
where <F as FormFields>::Field: Send,

§

impl<F> Sync for FieldErrors<F>
where <F as FormFields>::Field: Sync,

§

impl<F> Unpin for FieldErrors<F>
where <F as FormFields>::Field: Unpin,

§

impl<F> UnsafeUnpin for FieldErrors<F>

§

impl<F> UnwindSafe for FieldErrors<F>
where <F as FormFields>::Field: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more