Habilidades data-validation
🔍

data-validation

Baixo Risco ⚡ Contém scripts📁 Acesso ao sistema de arquivos🌐 Acesso à rede

使用 Pydantic 和 Zod 模式验证数据

手动进行数据验证容易出错。本技能提供 Pydantic 和 Zod 模式的专家级模式,使您能够构建类型安全的验证管道,及早捕获错误并防止有害数据进入系统。

Suporta: Claude Codex Code(CC)
📊 70 Adequado
1

Baixar o ZIP da skill

2

Upload no Claude

Vá em Configurações → Capacidades → Skills → Upload skill

3

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 Risco
v5 • 1/16/2026

This 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.

3
Arquivos analisados
913
Linhas analisadas
3
achados
5
Total de auditorias

Fatores de risco

⚡ Contém scripts (1)
📁 Acesso ao sistema de arquivos (1)
🌐 Acesso à rede (1)
Auditado por: claude Ver Histórico de Auditoria →

Pontuação de qualidade

45
Arquitetura
100
Manutenibilidade
83
Conteúdo
30
Comunidade
90
Segurança
87
Conformidade com especificações

O Que Você Pode Construir

API 负载验证

定义带字段约束、验证器和错误响应的 Pydantic 模型,适用于 FastAPI 端点

表单验证

构建带类型推断的 Zod 模式,与 React Hook Form 集成以进行实时验证

共享模式合同

使用共享常量和合同文档维护前端和后端之间一致的验证规则

Tente Estes Prompts

基础 Pydantic 模型
Create a Pydantic model for user registration with email, password, and name fields. Include min length, max length, and pattern constraints.
Zod 表单模式
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 版本?
Pydantic v2 需要 Python 3.8 或更高版本。大多数模式适用于 Python 3.8+。
我可以将这个与 FastAPI 一起使用吗?
可以。Pydantic 与 FastAPI 本地集成。在端点中使用 response_model,并在 Body 参数中使用 Pydantic 模型。
我验证的数据会被发送到任何地方吗?
不。此技能仅生成代码模式。您的验证完全在您的应用程序内运行。
如何处理验证错误?
将 Pydantic 的 ValidationError 与 detail 模式一起使用。在 API 中返回 422 状态码和结构化错误详情。
这与 Django 表单或 WTForms 有什么不同?
Pydantic 和 Zod 工作在 MVC 模式之外。它们专注于与展示逻辑分离的数据验证。

Detalhes do Desenvolvedor

Estrutura de arquivos

📁 scripts/

📄 verify.py

📄 SKILL.md