AgentSkillsCN

form-pattern

构建带有验证、错误提示与测试功能的类型化表单。

SKILL.md
--- frontmatter
name: form-pattern
description: Build a typed form with validation, errors, and tests.
disable-model-invocation: true

Form Pattern (SwiftUI)

Create a form that is typed, validated, accessible, and tested.

When to Use

  • When building any form or multi-step flow.

Inputs

  • Fields and validation rules
  • Submission behavior
  • Error and loading states

Instructions

  1. Define a typed form model and validation rules.
  2. Use Form and Section with explicit labels.
  3. Map server errors to field-level errors.
  4. Add XCTest coverage for validation logic.

Output

  • Form views and validation logic with tests.