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:
- Check if the field exists in the data
- Check if the field value is not null
- Check if the field value is not undefined
- Check if the field value is not an empty string
- 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:
- Check if the field exists in the data
- 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
- 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:
- Check if the field exists in the data
- If it exists, check if the value is of type number
- If not a number, add an error: "Field '[field_name]' must be a number"
Step 5: Report Results
- Collect all validation errors
- If no errors: Report that validation passed
- 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:
- Check required fields:
- Check email format:
- Check numeric fields:
- 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:
- Check required fields:
- "name" does not exist ✗
- "email" exists ✓
- 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:
- Check required fields: Both exist ✓
- Check email format:
- "invalid-email" does not contain @ ✗
- 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:
- Check required fields:
- "name" is empty string ✗
- "email" exists ✓
- Check email format:
- "bad-email" invalid format ✗
- Check numeric fields:
- "age" is "25" (string, not number) ✗
- 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:
- Check required fields:
- Check email fields:
- "email" field not in data, but not required, so skip ✓
- "phone" field exists but no rules apply to it ✓
- 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
1---2name: data-validator3description: 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.4license: MIT5metadata:6 source: https://skillmd.com/skills/egermano/data-validator7 author: agent-skills-poc8 version: "1.0"9 category: validation10---1112# Data Validator Skill1314This skill validates data structures against specified validation rules.1516## When to Use1718Use this skill when:19- The user needs to validate form data or user inputs20- Data integrity needs to be verified21- Email addresses need format validation22- Required fields need to be checked23- Numeric type validation is needed24- The user mentions terms like "validate", "check data", "verify", "validation rules", "required fields"2526## Instructions2728### Step 1: Understand the Validation Rules2930Identify which validation rules to apply:31- **Required fields**: Fields that must be present and non-empty32- **Email fields**: Fields that must contain valid email addresses33- **Numeric fields**: Fields that must contain numeric values3435### Step 2: Check Required Fields3637For each field in the required fields list:381. Check if the field exists in the data392. Check if the field value is not null403. Check if the field value is not undefined414. Check if the field value is not an empty string425. If any check fails, add an error: "Field '[field_name]' is required"4344### Step 3: Validate Email Fields4546For each field in the email fields list:471. Check if the field exists in the data482. If it exists and is a string, validate the email format:49 - Must contain exactly one @ symbol50 - Must have characters before the @51 - Must have characters after the @52 - Must have a dot (.) after the @53 - Must have characters after the final dot543. If validation fails, add an error: "Field '[field_name]' must be a valid email address"5556### Step 4: Validate Numeric Fields5758For each field in the numeric fields list:591. Check if the field exists in the data602. If it exists, check if the value is of type number613. If not a number, add an error: "Field '[field_name]' must be a number"6263### Step 5: Report Results64651. Collect all validation errors662. If no errors: Report that validation passed673. If errors exist: List all validation errors clearly6869## Examples7071### Example 1: Valid User Data72**Input:** 73- Data: `{ name: "John Doe", email: "john@example.com", age: 30 }`74- Rules: Required fields: ["name", "email"], Email fields: ["email"], Numeric fields: ["age"]7576**Steps:**771. Check required fields:78 - "name" exists and is "John Doe" ✓79 - "email" exists and is "john@example.com" ✓802. Check email format:81 - "john@example.com" matches email pattern ✓823. Check numeric fields:83 - "age" is 30 (number) ✓844. No errors found8586**Output:** "Validation passed. All fields are valid."8788### Example 2: Missing Required Field89**Input:**90- Data: `{ email: "john@example.com" }`91- Rules: Required fields: ["name", "email"]9293**Steps:**941. Check required fields:95 - "name" does not exist ✗96 - "email" exists ✓972. Error found: "Field 'name' is required"9899**Output:** "Validation failed with 1 error: Field 'name' is required"100101### Example 3: Invalid Email Format102**Input:**103- Data: `{ name: "John", email: "invalid-email" }`104- Rules: Required fields: ["name", "email"], Email fields: ["email"]105106**Steps:**1071. Check required fields: Both exist ✓1082. Check email format:109 - "invalid-email" does not contain @ ✗1103. Error found: "Field 'email' must be a valid email address"111112**Output:** "Validation failed with 1 error: Field 'email' must be a valid email address"113114### Example 4: Multiple Validation Errors115**Input:**116- Data: `{ name: "", email: "bad-email", age: "25" }`117- Rules: Required fields: ["name", "email"], Email fields: ["email"], Numeric fields: ["age"]118119**Steps:**1201. Check required fields:121 - "name" is empty string ✗122 - "email" exists ✓1232. Check email format:124 - "bad-email" invalid format ✗1253. Check numeric fields:126 - "age" is "25" (string, not number) ✗1274. Three errors found128129**Output:** 130```131Validation failed with 3 errors:1321. Field 'name' is required1332. Field 'email' must be a valid email address1343. Field 'age' must be a number135```136137### Example 5: Optional Fields138**Input:**139- Data: `{ name: "John", phone: "123-456-7890" }`140- Rules: Required fields: ["name"], Email fields: ["email"]141142**Steps:**1431. Check required fields:144 - "name" exists ✓1452. Check email fields:146 - "email" field not in data, but not required, so skip ✓1473. "phone" field exists but no rules apply to it ✓1484. No errors found149150**Output:** "Validation passed. All required fields are valid."151152## Common Edge Cases153154- **Empty strings**: Treat as missing for required field validation155- **Null vs undefined**: Both should fail required field validation156- **Whitespace-only strings**: Consider whether to treat as empty157- **Case sensitivity**: Email validation should be case-insensitive158- **Numeric strings**: "123" as a string should fail numeric validation159- **Zero values**: 0 is a valid number and should pass numeric validation160- **Extra fields**: Fields not mentioned in rules should be ignored161- **Email edge cases**: Handle emails with multiple dots, plus signs, etc.162163## Email Validation Pattern164165A valid email must match this pattern:166- Format: `local-part@domain`167- Local part: One or more characters before @168- Domain: One or more characters, must contain at least one dot169- Example valid emails: `user@example.com`, `john.doe@company.co.uk`, `test+tag@domain.com`170- Example invalid emails: `@example.com`, `user@`, `user`, `user@domain`, `user @example.com`171172## Tips173174- Always list all validation errors, not just the first one175- Be specific in error messages (include the field name)176- Consider the order of validation (check required first, then format)177- Provide clear feedback on what passed and what failed178- If validating multiple records, validate each independently