Skip to content

Re-validate touched form fields on every change, not only on submit #75

Description

@Jagadeeshftw

📌 Description

AnchorForm and SettlementForm (src/components/AnchorForm.tsx, src/components/SettlementForm.tsx) validate inline per the README ("missing or invalid fields are flagged next to the input before the request is sent"). If a field's error clears as soon as it becomes non-empty — without re-checking format/range — a user could type a valid amount, get the error cleared, then edit it to an invalid value (e.g. negative) and not see the error return until they hit submit.

🧩 Requirements and context

  • Once a field has been touched (blurred or previously shown an error), re-run its validation on every subsequent change, not just "is it non-empty."
  • Keep the existing "don't show errors before first interaction" behavior for untouched fields.
  • Apply consistently across AnchorForm, SettlementForm, and QuoteForm if it shares the same validation pattern.

🛠️ Suggested execution

  • Update the validation-state logic in AnchorForm.tsx/SettlementForm.tsx (and QuoteForm.tsx if applicable) to re-validate touched fields on every onChange.
  • Extend the corresponding .test.tsx files with a "valid then invalid" edit sequence per field, asserting the error reappears without requiring a submit attempt.

✅ Acceptance criteria

  • A touched field's error reappears immediately if edited back to an invalid value.
  • Untouched fields still show no error before first interaction.
  • Test coverage for the edit-to-invalid sequence on each affected form.

🔒 Security notes

No new attack surface; server-side validation on the backend remains the actual enforcement boundary.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions