$120 tested Claude codes · real before/after data · Full tier $15 one-timebuy --sheet=15 →
$Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. download --free →
clskills.sh — terminal v2.4 — 2,347 skills indexed● online
[CL]Skills_
Data & Analyticsintermediate

Data Validator

Share

Validate data integrity and format

Works with OpenClaude

You are a data validation specialist. The user wants to validate data integrity and format using a robust validation library with custom rules, error handling, and schema enforcement.

What to check first

  • Check if zod or joi is installed: npm list zod joi
  • Verify the data source structure (JSON, CSV, database object, or API response)
  • Identify required vs optional fields and their expected types

Steps

  1. Import the validation library (zod is recommended for TypeScript): import { z } from 'zod'
  2. Define a schema object that specifies field types, constraints, and custom rules using .string(), .number(), .array(), .object(), etc.
  3. Add validation rules like .min(), .max(), .email(), .url(), .regex() for format enforcement
  4. Use .refine() or .superRefine() to add custom cross-field validation logic
  5. Call .parse() to validate and throw on failure, or .safeParse() to return a result object with error details
  6. Handle validation errors by checking result.success and accessing result.error.errors for detailed messages
  7. Map validation errors to user-friendly messages or log structured error data
  8. Test with both valid data (should pass) and invalid data (should fail with expected error messages)

Code

import { z, ZodError } from 'zod';

// Define a comprehensive schema
const userSchema = z.object({
  id: z.number().int().positive(),
  email: z.string().email('Invalid email format'),
  username: z.string().min(3, 'Username must be at least 3 characters').max(20),
  age: z.number().int().min(0).max(150).optional(),
  password: z.string().min(8, 'Password must be at least 8 characters'),
  role: z.enum(['admin', 'user', 'moderator']),
  tags: z.array(z.string()).min(1, 'At least one tag required'),
  profile: z.object({
    bio: z.string().max(500).optional(),
    avatar: z.string().url('Invalid avatar URL').optional(),
  }).optional(),
}).strict(); // Disallow extra fields

// Custom validation with cross-field logic
const registrationSchema = userSchema.refine(
  (data) => data.password !== data.username,
  {
    message: 'Password cannot be the same as username',
    path: ['password'], // Error attached to this field
  }
);

// Validation function with error handling
function validateUser(data: unknown) {
  const result = registrationSchema.safeParse(data);

  if (!result.success) {
    // Structured error response
    const errors = result.error.errors.map((err) => ({
      field: err.path.join('.'),
      message: err.message,
      code: err

Note: this example was truncated in the source. See the GitHub repo for the latest full version.

Common Pitfalls

  • Treating this skill as a one-shot solution — most workflows need iteration and verification
  • Skipping the verification steps — you don't know it worked until you measure
  • Applying this skill without understanding the underlying problem — read the related docs first

When NOT to Use This Skill

  • When a simpler manual approach would take less than 10 minutes
  • On critical production systems without testing in staging first
  • When you don't have permission or authorization to make these changes

How to Verify It Worked

  • Run the verification steps documented above
  • Compare the output against your expected baseline
  • Check logs for any warnings or errors — silent failures are the worst kind

Production Considerations

  • Test in staging before deploying to production
  • Have a rollback plan — every change should be reversible
  • Monitor the affected systems for at least 24 hours after the change

Quick Info

Difficultyintermediate
Version1.0.0
AuthorClaude Skills Hub
datavalidationintegrity

Install command:

curl -o ~/.claude/skills/data-validator.md https://claude-skills-hub.vercel.app/skills/data/data-validator.md

Related Data & Analytics Skills

Other Claude Code skills in the same category — free to download.

Want a Data & Analytics skill personalized to YOUR project?

This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.