feat(forms): shared FormGuard submit guard (PMS-517) #351
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/PMS-517-form-submit-guard"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Second foundation piece for the PMS-515 epic (PMS-516 is now merged on
main). AddsFormGuard(src/utils/form_guard.rs), the submit-time counterpart to the per-field blur validation from PMS-516.How
A submit handler runs each required field through the guard, then bails if blocked:
field(id, value, label, rules) -> Stringreturns that field's message (empty when valid, clearing a stale message) and records the first invalid field. The caller sets its own error signal with the return value.note_invalid(focus_id)covers cross-field / non-field failures (XOR pickers, server-only errors) with no inline slot.blocked()focuses the first invalid field and returns whether to abort the submit.Generalizes the per-field PMS-514 fix into one reusable helper: every failing field surfaces at once (each into its own inline slot), submit is blocked while any field is invalid, first invalid field is focused.
Design notes
<form onsubmit>page forms andonclick-submit modals. Avoids the re-render / hook-ordering pitfalls of an auto-registration context.focus_fieldis gated ontarget_arch = "wasm32"(repoweb_sysconvention,lib.rs:80):web_sysimports panic off-wasm and thewebfeature is on even for host test builds, so on host/test it is a no-op. (Real bug caught by the unit tests on first run.)Scope
Delivers the guard helper + tests. Adopting it across the ~30 forms and deleting the bespoke per-handler checks is PMS-518.
Verification
just checkparity (rust-builder image):clippy --all-targets -- -D warnings,fmt --check,cargo test --lib form_guard(7 passed),cargo check --target wasm32-unknown-unknown- all green.Acceptance criteria (PMS-517)
note_invalid+ the handler's form-level banner).onsubmitpage forms andonclick-submit modals.just checkgreen.