pub struct FormErrors { /* private fields */ }Expand description
The problems of a form, in the order the application found them, each under the name of the control it belongs to.
Validation stays in the application: it checks its values and records a message for every
problem. Use the same name for the error and the control’s NodeMut::id,
so FormErrors::focus_first can take the user to the first problem.
use qframe::widgets::FormErrors;
let name = "ab";
let mut errors = FormErrors::new();
errors.check("name", name.chars().count() >= 3, "Use at least 3 characters");
assert_eq!(errors.get("name"), Some("Use at least 3 characters"));
assert_eq!(errors.first(), Some("name"));Implementations§
Source§impl FormErrors
impl FormErrors
Sourcepub fn set(&mut self, name: impl Into<String>, message: impl Into<String>)
pub fn set(&mut self, name: impl Into<String>, message: impl Into<String>)
Records message for control name, replacing an earlier message for it.
Sourcepub fn check(
&mut self,
name: impl Into<String>,
valid: bool,
message: impl Into<String>,
)
pub fn check( &mut self, name: impl Into<String>, valid: bool, message: impl Into<String>, )
Records message for name when valid is false and forgets any problem of name
when it is true.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &str)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &str)>
Every problem as (name, message), in order.
Sourcepub fn focus_first<Msg: Send + 'static>(&self) -> Command<Msg>
pub fn focus_first<Msg: Send + 'static>(&self) -> Command<Msg>
Moves focus to the control of the first problem; nothing when there are none.
Trait Implementations§
Source§impl Clone for FormErrors
impl Clone for FormErrors
Source§fn clone(&self) -> FormErrors
fn clone(&self) -> FormErrors
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FormErrors
impl Debug for FormErrors
Source§impl Default for FormErrors
impl Default for FormErrors
Source§fn default() -> FormErrors
fn default() -> FormErrors
Returns the “default value” for a type. Read more
impl Eq for FormErrors
Source§impl PartialEq for FormErrors
impl PartialEq for FormErrors
impl StructuralPartialEq for FormErrors
Auto Trait Implementations§
impl Freeze for FormErrors
impl RefUnwindSafe for FormErrors
impl Send for FormErrors
impl Sync for FormErrors
impl Unpin for FormErrors
impl UnsafeUnpin for FormErrors
impl UnwindSafe for FormErrors
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more