1075551341/claude_code_config/data-validation
Claude Code and agent skill by 1075551341/claude_code_config
Trust tier 2
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
验证输入数据、校验请求参数、使用Zod/Joi/Pydantic进行数据校验
Install
npx vskill@latest install 1075551341/claude_code_config/data-validationSKILL.md
The same SKILL.md was published earlier as 1075551341/claude_code_config/data-validation.
数据校验
描述
请求参数与数据模型校验方案,涵盖 Zod、Joi、class-validator、Pydantic 等主流校验库
触发条件
当用户提到:数据校验、参数校验、Zod、Joi、Yup、class-validator、Pydantic、表单验证、Schema 校验、输入验证、类型校验 时使用此技能
方案选型
| 场景 | 推荐方案 | 适用范围 | |
|---|---|---|---|
| TypeScript 全栈 | Zod | 前后端共享 Schema,类型推导强 | |
| Express/Koa | Joi / Zod | 中间件式校验 | |
| NestJS | class-validator + class-transformer | 装饰器风格 | |
| 前端表单 | Zod + react-hook-form | React 表单 | |
| Python API | Pydantic v2 | FastAPI 原生集成 | |
| Python 通用 | marshmallow / cerberus | Flask/Django 场景 |
核心代码示例
TypeScript - Zod 全栈校验
TypeScript - Zod + react-hook-form
Python - Pydantic v2 校验
最佳实践
- 前后端共享 → Zod Schema 定义一次,前端表单 + 后端接口共用
- 永远不信前端 → 即使前端已校验,后端必须再次校验
- 友好提示 → 校验错误返回字段名 + 中文描述,前端直接展示
- 白名单模式 → 只接受已定义字段,strip 未知字段(Zod
.strict()) - 组合复用 → 基础 Schema 通过
.pick()/.extend()派生变体 - 自定义校验 → 业务规则(如唯一性检查)放在 Service 层,不混入 Schema
- 错误码统一 → 校验失败统一返回 400 + 结构化错误列表
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingcatalog/skills/data-validation/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/1075551341/claude_code_config/data-validation)