agentleFS
agentsdanceagentsdance/agentskills/skills/data-validator/SKILL.md

data-validator

Skill3 starsChanged 11 months agoApache-2.0View on GitHub

Validate data quality and integrity. Use when the user needs to check data consistency, find anomalies, or ensure data meets quality standards.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

Files
SKILL.md

Data Validator

Validate data quality, consistency, and integrity.

Validation Rules

class DataValidator {
  constructor(rules) {
    this.rules = rules;
    this.errors = [];
  }

  validate(data) {
    this.errors = [];

    for (const [field, fieldRules] of Object.entries(this.rules)) {
      const value = data[field];

      for (const rule of fieldRules) {
        const error = rule(value, field, data);
        if (error) {
          this.errors.push({ field, message: error });
        }
      }
    }

    return this.errors.length === 0;
  }
}

// Rule functions
const required = (value, field) =>
  value == null || value === '' ? `${field} is required` : null;

const email = (value, field) =>
  value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)
    ? `${field} must be a valid email`
    : null;

const minLength = (min) => (value, field) =>
  value && value.length < min
    ? `${field} must be at least ${min} characters`
    : null;

const range = (min, max) => (value, field) =>
  value != null && (value < min || value > max)
    ? `${field} must be between ${min} and ${max}`
    : null;

// Usage
const validator = new DataValidator({
  email: [required, email],
  password: [required, minLength(8)],
  age: [range(0, 150)],
});

validator.validate({ email: 'invalid', password: '123' });
// errors: [{ field: 'email', message: '...' }, ...]

Data Quality Checks (Python)

import pandas as pd

class DataQualityChecker:
    def __init__(self, df):
        self.df = df
        self.issues = []

    def check_nulls(self, columns, threshold=0.1):
        """Check for excessive null values."""
        for col in columns:
            null_ratio = self.df[col].isnull().mean()
            if null_ratio > threshold:
                self.issues.append({
                    'check': 'null_ratio',
                    'column': col,
                    'value': f'{null_ratio:.2%}',
                    'threshold': f'{threshold:.2%}'
                })

    def check_duplicates(self, columns):
        """Check for duplicate rows."""
        duplicates = self.df.duplicated(subset=columns).sum()
        if duplicates > 0:
            self.issues.append({
                'check': 'duplicates',
                'columns': columns,
                'count': duplicates
            })

    def check_range(self, column, min_val, max_val):
        """Check values are within expected range."""
        out_of_range = self.df[
            (self.df[column] < min_val) | (self.df[column] > max_val)
        ]
        if len(out_of_range) > 0:
            self.issues.append({
                'check': 'range',
                'column': column,
                'count': len(out_of_range)
            })

    def check_unique(self, column):
        """Check column has unique values."""
        if self.df[column].duplicated().any():
            self.issues.append({
                'check': 'unique',
                'column': column,
                'duplicates': self.df[column].duplicated().sum()
            })

    def report(self):
        if not self.issues:
            print("All checks passed!")
        else:
            for issue in self.issues:
                print(f"Issue: {issue}")

SQL Data Validation

-- Check for nulls
SELECT COUNT(*) AS null_count
FROM users
WHERE email IS NULL;

-- Check for duplicates
SELECT email, COUNT(*) as count
FROM users
GROUP BY email
HAVING COUNT(*) > 1;

-- Check referential integrity
SELECT o.id
FROM orders o
LEFT JOIN users u ON o.user_id = u.id
WHERE u.id IS NULL;

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.