← 返回
未分类 中文

Form Validation

Deep form validation workflow—schemas, sync vs async rules, UX patterns, accessibility, and server parity. Use when building complex forms, multi-step wizard...
深度表单验证工作流——模式、同步/异步规则、UX模式、无障碍与服务器一致性。适用于复杂表单、多步骤向导等。
mike47512 mike47512 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 1
Stars
📥 422
下载
💾 0
安装
1
版本
#latest

概述

Form Validation

Validation combines correctness and UX: when errors appear, how they are announced, and how client rules match the server.

When to Offer This Workflow

Trigger conditions:

  • Long forms, wizards, or multi-step checkouts
  • Accessibility audits flagging unclear errors
  • Mismatch between client-side “valid” and API rejection

Initial offer:

Use six stages: (1) model & schema, (2) rule layers, (3) UX timing, (4) accessibility, (5) async & server parity, (6) testing). Confirm framework (React Hook Form, Formik, native, etc.).


Stage 1: Model & Schema

Goal: Single schema (Zod, Yup, JSON Schema) as source of truth; share with backend when feasible.


Stage 2: Rule Layers

Goal: Separate required/format rules from cross-field rules (e.g., date range); isolate async checks (username available) from fast inline validation.


Stage 3: UX Timing

Goal: Choose onBlur vs onSubmit per field; avoid shouting on every keystroke unless real-time feedback is a product requirement.


Stage 4: Accessibility

Goal: Associate errors with fields via aria-describedby; move focus to first error on submit; use live regions judiciously.


Stage 5: Async & Server Parity

Goal: Map API validation errors to fields; handle race conditions on slow networks; idempotent submit with dedupe if needed.


Stage 6: Testing

Goal: Unit-test schema; e2e critical paths including server error mapping.


Final Review Checklist

  • [ ] Schema aligned or shared with server
  • [ ] Validation timing and copy defined
  • [ ] Accessible error patterns
  • [ ] API errors mapped to UI
  • [ ] Tests for schema and flows

Tips for Effective Guidance

  • Server rules always win—document intentional client shortcuts.
  • Pair with ux-writing for error microcopy.

Handling Deviations

  • Wizards: validate per step and on final submit; persist drafts securely.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-31 08:01 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

design-media

Visual

mike47512
提供平面设计、UI交互、PPT美化及品牌调性升级指引。
★ 0 📥 2,059
dev-programming

Mcporter

steipete
使用 mcporter CLI 直接列出、配置、认证及调用 MCP 服务器/工具(支持 HTTP 或 stdio),涵盖临时服务器、配置编辑及 CLI/类型生成功能。
★ 195 📥 67,533
dev-programming

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 677 📥 326,757