pub struct ValidationErrors { /* private fields */ }Expand description
HeroUI v3’s ValidationErrors — Record<string, string | string[]>, the
server-side errors Form maps by field name.
The record is a name-keyed mapping, not a message list: the form routes each entry into the named field’s own error slot, never into a form-level stack. Names the fields do not register display nowhere and block nothing.
Identity is part of the contract. Delivery is keyed to Self::revision,
not to equality:
- a
clonekeeps its revision, so re-rendering with the same record never resurrects a message the user edited away; - any freshly built record —
new,defaultorset— mints a new revision and re-arms every named field, even when the content equals the old record (a server that re-sends the same error is a new response, not silence).
The caller half of that contract: retain one record for as long as a
response is current — in app state, a thread_local, wherever the frame
rebuilds from — and hand the form a Clone of it every frame.
Constructing a fresh record per frame (ValidationErrors::new(), or
re-running the builder chain in render) is a brand-new server response
every frame and re-arms every named field every frame, however equal the
content looks. This is exactly React Stately’s reference identity: what
re-arms is a new record, never a re-sent one.
PartialEq compares content only, so records can be compared while the
identity stays a separate, explicit question.
Implementations§
Source§impl ValidationErrors
impl ValidationErrors
Sourcepub fn revision(&self) -> u64
pub fn revision(&self) -> u64
The record’s identity. Two records with equal content but different revisions are two different responses; a clone shares the revision.
Sourcepub fn get(&self, name: &str) -> Option<&[SharedString]>
pub fn get(&self, name: &str) -> Option<&[SharedString]>
The messages recorded for name — record[name], None when absent.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&SharedString, &[SharedString])>
pub fn iter(&self) -> impl Iterator<Item = (&SharedString, &[SharedString])>
Iterates (name, messages) in deterministic name order.
Sourcepub fn names(&self) -> impl Iterator<Item = &SharedString>
pub fn names(&self) -> impl Iterator<Item = &SharedString>
The names carrying at least one message, in deterministic name order.
Sourcepub fn set(
self,
name: impl Into<SharedString>,
message: impl Into<SharedString>,
) -> Self
pub fn set( self, name: impl Into<SharedString>, message: impl Into<SharedString>, ) -> Self
record[name] = message — the single-message spelling.
Rebuilding a record is a new response: the revision is minted, so a form handed the result re-arms its fields.
Sourcepub fn set_many(
self,
name: impl Into<SharedString>,
messages: impl IntoIterator<Item = impl Into<SharedString>>,
) -> Self
pub fn set_many( self, name: impl Into<SharedString>, messages: impl IntoIterator<Item = impl Into<SharedString>>, ) -> Self
record[name] = [m0, m1, ...] — the multiple-messages spelling, shown
in the order given.
Trait Implementations§
Source§impl Clone for ValidationErrors
impl Clone for ValidationErrors
Source§impl Debug for ValidationErrors
impl Debug for ValidationErrors
Source§impl Default for ValidationErrors
impl Default for ValidationErrors
impl Eq for ValidationErrors
Source§impl PartialEq for ValidationErrors
impl PartialEq for ValidationErrors
Auto Trait Implementations§
impl Freeze for ValidationErrors
impl RefUnwindSafe for ValidationErrors
impl Send for ValidationErrors
impl Sync for ValidationErrors
impl Unpin for ValidationErrors
impl UnsafeUnpin for ValidationErrors
impl UnwindSafe for ValidationErrors
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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§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
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().