# Data Validator

> Validates data against specified rules including required field checks, email format validation, and numeric type verification. Use when the user needs to verify data integrity, validate form inputs, or check data against business rules.

- Skill: `egermano/data-validator` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add egermano/data-validator`
- Raw SKILL.md: https://api.skillmd.com/api/skills/egermano/data-validator/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Productivity
- License: MIT
- Author: egermano (https://skillmd.com/u/egermano)
- Updated: 2026-09-10
- Page: https://skillmd.com/skills/egermano/data-validator

---


# Data Validator Skill

This skill validates data structures against specified validation rules.

## When to Use

Use this skill when:
- The user needs to validate form data or user inputs
- Data integrity needs to be verified
- Email addresses need format validation
- Required fields need to be checked
- Numeric type validation is needed
- The user mentions terms like "validate", "check data", "verify", "validation rules", "required fields"

## Instructions

### Step 1: Understand the Validation Rules

Identify which validation rules to apply:
- **Required fields**: Fields that must be present and non-empty
- **Email fields**: Fields that must contain valid email addresses
- **Numeric fields**: Fields that must contain numeric values

### Step 2: Check Required Fields

For each field in the required fields list:
1. Check if the field exists in the data
2. Check if the field value is not null
3. Check if the field value is not undefined
4. Check if the field value is not an empty string
5. If any check fails, add an error: "Field '[field_name]' is required"

### Step 3: Validate Email Fields

For each field in the email fields list:
1. Check if the field exists in the data
2. If it exists and is a string, validate the email format:
   - Must contain exactly one @ symbol
   - Must have characters before the @
   - Must have characters after the @
   - Must have a dot (.) after the @
   - Must have characters after the final dot
3. If validation fails, add an error: "Field '[field_name]' must be a valid email address"

### Step 4: Validate Numeric Fields

For each field in the numeric fields list:
1. Check if the field exists in the data
2. If it exists, check if the value is of type number
3. If not a number, add an error: "Field '[field_name]' must be a number"

### Step 5: Report Results

1. Collect all validation errors
2. If no errors: Report that validation passed
3. If errors exist: List all validation errors clearly

## Examples

### Example 1: Valid User Data
**Input:** 
- Data: `{ name: "John Doe", email: "john@example.com", age: 30 }`
- Rules: Required fields: ["name", "email"], Email fields: ["email"], Numeric fields: ["age"]

**Steps:**
1. Check required fields:
   - "name" exists and is "John Doe" ✓
   - "email" exists and is "john@example.com" ✓
2. Check email format:
   - "john@example.com" matches email pattern ✓
3. Check numeric fields:
   - "age" is 30 (number) ✓
4. No errors found

**Output:** "Validation passed. All fields are valid."

### Example 2: Missing Required Field
**Input:**
- Data: `{ email: "john@example.com" }`
- Rules: Required fields: ["name", "email"]

**Steps:**
1. Check required fields:
   - "name" does not exist ✗
   - "email" exists ✓
2. Error found: "Field 'name' is required"

**Output:** "Validation failed with 1 error: Field 'name' is required"

### Example 3: Invalid Email Format
**Input:**
- Data: `{ name: "John", email: "invalid-email" }`
- Rules: Required fields: ["name", "email"], Email fields: ["email"]

**Steps:**
1. Check required fields: Both exist ✓
2. Check email format:
   - "invalid-email" does not contain @ ✗
3. Error found: "Field 'email' must be a valid email address"

**Output:** "Validation failed with 1 error: Field 'email' must be a valid email address"

### Example 4: Multiple Validation Errors
**Input:**
- Data: `{ name: "", email: "bad-email", age: "25" }`
- Rules: Required fields: ["name", "email"], Email fields: ["email"], Numeric fields: ["age"]

**Steps:**
1. Check required fields:
   - "name" is empty string ✗
   - "email" exists ✓
2. Check email format:
   - "bad-email" invalid format ✗
3. Check numeric fields:
   - "age" is "25" (string, not number) ✗
4. Three errors found

**Output:** 
```
Validation failed with 3 errors:
1. Field 'name' is required
2. Field 'email' must be a valid email address
3. Field 'age' must be a number
```

### Example 5: Optional Fields
**Input:**
- Data: `{ name: "John", phone: "123-456-7890" }`
- Rules: Required fields: ["name"], Email fields: ["email"]

**Steps:**
1. Check required fields:
   - "name" exists ✓
2. Check email fields:
   - "email" field not in data, but not required, so skip ✓
3. "phone" field exists but no rules apply to it ✓
4. No errors found

**Output:** "Validation passed. All required fields are valid."

## Common Edge Cases

- **Empty strings**: Treat as missing for required field validation
- **Null vs undefined**: Both should fail required field validation
- **Whitespace-only strings**: Consider whether to treat as empty
- **Case sensitivity**: Email validation should be case-insensitive
- **Numeric strings**: "123" as a string should fail numeric validation
- **Zero values**: 0 is a valid number and should pass numeric validation
- **Extra fields**: Fields not mentioned in rules should be ignored
- **Email edge cases**: Handle emails with multiple dots, plus signs, etc.

## Email Validation Pattern

A valid email must match this pattern:
- Format: `local-part@domain`
- Local part: One or more characters before @
- Domain: One or more characters, must contain at least one dot
- Example valid emails: `user@example.com`, `john.doe@company.co.uk`, `test+tag@domain.com`
- Example invalid emails: `@example.com`, `user@`, `user`, `user@domain`, `user @example.com`

## Tips

- Always list all validation errors, not just the first one
- Be specific in error messages (include the field name)
- Consider the order of validation (check required first, then format)
- Provide clear feedback on what passed and what failed
- If validating multiple records, validate each independently

