data-validation
使用 Pydantic 和 Zod 模式验证数据
手动进行数据验证容易出错。本技能提供 Pydantic 和 Zod 模式的专家级模式,使您能够构建类型安全的验证管道,及早捕获错误并防止有害数据进入系统。
Baixar o ZIP da skill
Upload no Claude
Vá em Configurações → Capacidades → Skills → Upload skill
Ative e comece a usar
Testar
A utilizar "data-validation". Create a Pydantic model for user registration with email, password, and name fields
Resultado esperado:
- ✓ Created UserCreate model with Field constraints
- ✓ Added EmailStr validation for email field
- ✓ Included password min_length=8 and pattern requirements
- ✓ Added model_validator for confirm_password matching
- ✓ Configured JSON schema with examples
Auditoria de Segurança
Baixo RiscoThis is a documentation skill containing validation patterns for Pydantic and Zod. The only executable code is scripts/verify.py, a 62-line YAML frontmatter validator that reads SKILL.md and prints validation results. No network calls, no credential access, no file writes beyond stdout. All 37 HIGH findings (weak crypto, C2 keywords) and 32 MEDIUM findings (backtick execution) are false positives: regex patterns for YAML parsing were misidentified as crypto, and markdown code formatting was misidentified as shell execution.
Fatores de risco
⚡ Contém scripts (1)
📁 Acesso ao sistema de arquivos (1)
🌐 Acesso à rede (1)
Pontuação de qualidade
O Que Você Pode Construir
API 负载验证
定义带字段约束、验证器和错误响应的 Pydantic 模型,适用于 FastAPI 端点
表单验证
构建带类型推断的 Zod 模式,与 React Hook Form 集成以进行实时验证
共享模式合同
使用共享常量和合同文档维护前端和后端之间一致的验证规则
Tente Estes Prompts
Create a Pydantic model for user registration with email, password, and name fields. Include min length, max length, and pattern constraints.
Build a Zod schema for a contact form with name, email, message fields. Add required field and email validation.
Add a Pydantic model_validator that checks date_of_birth is in the past and age is between 18 and 120.
Create a sanitize_for_database function that strips HTML tags and limits string length to prevent XSS attacks.
Melhores Práticas
- 将输入模型(创建/更新)与输出模型分开,以防止批量赋值漏洞
- 即使存在客户端验证,也始终在后端重新验证,以防止绕过攻击
- 尽可能使用类型安全的验证器,如 EmailStr 和 Field 约束,而非自定义正则表达式
Evitar
- 仅信任客户端验证而不进行后端重新验证
- 使用暴露内部验证细节给用户的通用异常处理
- 在响应模型中包含应仅存在于数据库中的敏感字段
Perguntas Frequentes
此技能在运行时验证数据吗?
支持哪些 Python 版本?
我可以将这个与 FastAPI 一起使用吗?
我验证的数据会被发送到任何地方吗?
如何处理验证错误?
这与 Django 表单或 WTForms 有什么不同?
Detalhes do Desenvolvedor
Autor
Awais68Licença
MIT
Repositório
https://github.com/Awais68/hackathon-2-phase-ii-full-stack-web-app/tree/main/.claude/skills/data-validationReferência
main