| name | data-validation-rules |
| description | Data Validation Rules are constraints and checks that ensure data meets\ Use when this capability is needed. |
| metadata | {"author":"amnadtaowsoam"} |
Data Validation Rules
Skill Profile
(Select at least one profile to enable specific modules)
Overview
Data Validation Rules are constraints and checks that ensure data meets quality standards before being stored or processed. Validation should happen at multiple layers—database, application, API, and pipeline—to create defense in depth.
Core Principle: "Validate early, validate often. Never trust user input or upstream data."
This skill provides comprehensive guidance on implementing validation rules across all layers of the data stack.
Why This Matters
Core Concepts & Rules
1. Core Principles
- Follow established patterns and conventions
- Maintain consistency across codebase
- Document decisions and trade-offs
2. Implementation Guidelines
- Start with the simplest viable solution
- Iterate based on feedback and requirements
- Test thoroughly before deployment
Inputs / Outputs / Contracts
- Inputs:
- <e.g., env vars, request payload, file paths, schema>
- Entry Conditions:
- <Pre-requisites: e.g., Repo initialized, DB running, specific branch checked out>
- Outputs:
- <e.g., artifacts (PR diff, docs, tests, dashboard JSON)>
- Artifacts Required (Deliverables):
- <e.g., Code Diff, Unit Tests, Migration Script, API Docs>
- Acceptance Evidence:
- <e.g., Test Report (screenshot/log), Benchmark Result, Security Scan Report>
- Success Criteria:
- <e.g., p95 < 300ms, coverage ≥ 80%>
Skill Composition
- Depends on: None
- Compatible with: None
- Conflicts with: None
- Related Skills: None
Quick Start
Assumptions
- Validation rules can be defined declaratively
- Team has capacity to maintain validation logic
- Performance requirements allow for validation overhead
- Error messages can be made user-friendly
Compatibility
- Works with any programming language
- Compatible with all major databases
- Framework-agnostic approach
- Adaptable to different validation libraries
Test Scenario Matrix
| Scenario | Test Case | Expected Outcome |
|---|
| Required field | Submit without required field | Validation error with clear message |
| Type mismatch | Submit string for number field | Validation error |
| Invalid format | Submit invalid email | Validation error |
| Out of range | Submit age = 200 | Validation error |
| Invalid enum | Submit invalid status | Validation error |
| Cross-field | End date before start date | Validation error |
Technical Guardrails & Security Threat Model
1. Security & Privacy (Threat Model)
- Top Threats: Injection attacks, authentication bypass, data exposure
2. Performance & Resources
3. Architecture & Scalability
4. Observability & Reliability
Agent Directives
- Validate everywhere - At database, application, API, and pipeline
- Fail fast - Reject invalid data as early as possible
- Meaningful errors - Provide clear, actionable error messages
- Test validation - Validation rules need testing too
- Document rules - Make validation visible to all
Definition of Done
Data validation implementation is complete when:
Anti-patterns
- Validating only at one layer - Need defense in depth
- Silent failures - Always return validation errors
- Generic error messages - Be specific about what's wrong
- Trusting upstream data - Validate everything
- Complex validation logic - Keep it simple and maintainable
Reference Links
Versioning
This skill follows semantic versioning (MAJOR.MINOR.PATCH):
- MAJOR: Breaking changes to procedures or standards
- MINOR: New validation methods or significant enhancements
- PATCH: Bug fixes or documentation updates
Converted and distributed by TomeVault — claim your Tome and manage your conversions.