Implement Robust Data Validation Rules
AI skill for designing data validation rules - JSON Schema, SQL constraints, and a configurable Python validator framework.
Why it matters
Ensure data quality, integrity, and consistency across your systems by implementing comprehensive data validation rules. This asset excels at designing and deploying validation frameworks that catch issues early and provide clear feedback.
Outcomes
What it gets done
Design and implement multi-layered validation (syntactic, semantic, cross-field, temporal, external).
Configure fail-fast vs. collect-all strategies for different validation needs.
Utilize JSON Schema and SQL constraints for structured validation.
Develop custom Python validation logic for complex business rules.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/vb-data-validation-rules | bash Overview
Data Validation Rules Expert Agent
Designs data validation rules - JSON Schema and SQL constraint definitions, and a configurable Python validator framework with reusable rules. Use when designing multi-layer validation for a data pipeline or application ingesting structured data from multiple sources.
What it does
This skill provides expertise in designing and implementing comprehensive data validation rules to ensure quality, integrity, and consistency across systems and processing pipelines, building frameworks that catch issues early, produce clear error messages, and maintain high data quality standards. Core validation principles cover validation layers - syntactic (format, type, structure), semantic (business rules and logic), cross-field (relationships between data elements), temporal (time-consistency checks), and external (reference-data and lookup checks) - and a fail-fast versus collect-all strategy, using fail-fast for critical structural problems while collecting all business-rule violations to give comprehensive feedback, with configurable validation modes for different use cases.
Schema-based validation covers JSON Schema validation (defining type, pattern, format, length, and range constraints per field, with required fields and additionalProperties: false to reject unexpected fields) and SQL constraint-based validation (table-level CHECK constraints for email format, future-date limits, and positive-price/valid-percentage rules, plus cross-table validation via a trigger function that raises an exception if an order's requested quantity exceeds available inventory).
The Python validation framework implements a DataValidator class supporting both fail-fast and collect-all modes, with per-field rules and cross-field rules registered separately, running all applicable rules against a data dict and aggregating errors/warnings into a ValidationResult (is_valid, errors, warnings, field_name). Reusable validation rules are implemented as composable rule factories - required() for null/blank checks, regex_pattern() for format validation with a custom error message, and numeric_range() for bounded numeric validation - each returning a standard ValidationResult so rules compose cleanly across fields.
When to use - and when NOT to
Use this skill when designing validation rules for a data pipeline or application that needs multi-layer checks (syntactic, semantic, cross-field) with clear, actionable error reporting. It is well suited to systems ingesting structured data from multiple sources needing consistent quality enforcement. It is not meant for trivial single-field validation with no cross-field or business-rule complexity, where a simple type check suffices.
Inputs and outputs
Input: the data schema/fields and the business rules that need enforcing.
Output: JSON Schema definitions, SQL constraints/triggers, and a configurable Python validation framework with reusable rules. Example reusable validation rule:
@staticmethod
def regex_pattern(pattern: str, message: str = "Invalid format") -> Callable:
def validate(value: Any) -> ValidationResult:
if not isinstance(value, str) or not re.match(pattern, value):
return ValidationResult(False, [message], [])
return ValidationResult(True, [], [])
return validate
Integrations
Works with JSON Schema (draft-07), SQL databases (CHECK constraints, PL/pgSQL triggers), and a standalone Python validation framework.
Who it's for
Data and backend engineers designing validation rules for data pipelines or applications, and teams that need configurable fail-fast versus collect-all validation with clear, field-attributed error messages.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.