pub struct FormState {
pub validate_mode: FormValidateMode,
pub submit_count: u64,
pub is_submitting: bool,
pub registered_fields: Vec<Arc<str>>,
pub dirty_fields: HashSet<Arc<str>>,
pub touched_fields: HashSet<Arc<str>>,
pub errors: HashMap<Arc<str>, Arc<str>>,
}Expand description
Headless form state (field meta + errors) intended for shadcn-style composition.
This type is intentionally value-agnostic:
- field values typically live in app-owned
Model<T>s (ADR 0031) - the form tracks lifecycle metadata (dirty/touched/submitting) and validation outcomes
Fields§
§validate_mode: FormValidateMode§submit_count: u64§is_submitting: bool§registered_fields: Vec<Arc<str>>§dirty_fields: HashSet<Arc<str>>§touched_fields: HashSet<Arc<str>>§errors: HashMap<Arc<str>, Arc<str>>Implementations§
Source§impl FormState
impl FormState
pub fn is_dirty(&self) -> bool
pub fn is_touched(&self) -> bool
pub fn is_valid(&self) -> bool
pub fn has_error(&self, field: &str) -> bool
pub fn error_for(&self, field: &str) -> Option<&Arc<str>>
pub fn is_registered(&self, field: &str) -> bool
pub fn register_field(&mut self, field: impl Into<Arc<str>>)
pub fn unregister_field(&mut self, field: &str)
pub fn touch(&mut self, field: impl Into<Arc<str>>)
pub fn touch_all_registered(&mut self)
pub fn set_dirty(&mut self, field: impl Into<Arc<str>>, dirty: bool)
pub fn set_error( &mut self, field: impl Into<Arc<str>>, message: impl Into<Arc<str>>, )
pub fn set_error_opt( &mut self, field: impl Into<Arc<str>>, message: Option<Arc<str>>, )
pub fn clear_error(&mut self, field: &str)
pub fn clear_errors(&mut self)
pub fn begin_submit(&mut self)
pub fn end_submit(&mut self)
pub fn reset(&mut self)
pub fn validate_field( &mut self, field: impl Into<Arc<str>>, validate: impl FnOnce() -> Option<Arc<str>>, ) -> bool
pub fn validate_registered_fields( &mut self, validate: impl FnMut(&Arc<str>) -> Option<Arc<str>>, ) -> bool
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FormState
impl RefUnwindSafe for FormState
impl Send for FormState
impl Sync for FormState
impl Unpin for FormState
impl UnsafeUnpin for FormState
impl UnwindSafe for FormState
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