npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

data-constraints

v1.0.2

Published

The easiest way to validate your data consistency. Ensure the quality of your files without writing code

Readme

Data Constraints

npm version License Node.js Coverage CI PRs Welcome

Data Constraints is the easiest way to validate your data streams. Whether you have small JSON files or massive CSV dumps, this tool ensures your data isn't garbage.


🚀 Why Data Constraints?

  • Rule-Based: Define your rules in simple JSON/YAML files. No coding required.
  • Universal: Works with JSON and CSV out of the box.
  • Developer Friendly: Written in JavaScript, typed with TypeScript.

⚡ Basic Use Case (At a glance)

Imagine you have a users.json file and you want to ensure all emails are valid.

1. Your Data (users.json):

[
  { "id": 1, "email": "[email protected]" },
  { "id": 2, "email": "bob-has-no-domain" }
]

2. Your Rules (config.json):

{
  "sources": {
    "users": { "type": "file", "path": "users.json", "format": "json" }
  },
  "constraints": [
    {
      "type": "format",
      "id": "valid-email",
      "service": "users",
      "field": "email",
      "regex": "^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$",
      "message": "Invalid email: {{email}}"
    }
  ]
}

3. Run and get results:

$ npx data-constraints validate --config config.json
[INFO] Validating data...
[valid-email] (format) Invalid email: bob-has-no-domain
Validation finished. Found 1 issues.

📦 Installation

To use as a CLI globally:

npm install -g data-constraints

Or install locally in your project:

npm install data-constraints

Then you can run npx data-constraints from your project folder.

🧠 Basic Concepts

Data Constraints works with three core files:

  1. Data Files: Your actual data dumps in .json or .csv format.
  2. Config File: A JSON file pointing the engine to your data and rules.
  3. Constraints (Rules): The definitions of what is valid.

Rule Types at a Glance

  • 📝 Format: Ensure strings look correct (e.g. Emails).
    • Example: "regex": "^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$"
  • 🆔 Unique: Ensure no duplicate IDs exist across a file.
    • Example: "field": "employee_id"
  • 🔗 Foreign Key: Ensure referenced IDs actually exist in another file.
    • Example: order.userId must exist in users.id

📚 Documentation

For full documentation, guides and advanced use cases, please check the docs/ directory.

  • Key Concepts: Easy-to-understand explanation of file types and constraints.
  • User Guide: The comprehensive guide to using the CLI and defining rules.
  • Integration Guide: How to integrate the engine programmatically in Node.js.
  • Examples: Runnable examples, ranging from simple to e-commerce.

🛠️ Features

| Feature | Description | | :--- | :--- | | Format Validation | Regex-based validation for strings (Emails, Phones, Codes). | | Unique Validation | Ensure IDs and codes are unique across your dataset. | | Foreign Keys | Validate relationships between different files (e.g. order.userId -> user.id). | | Multiple Reporters | Output results to Console, JSON, or Markdown files. |

🤝 Contributing

In Data Constraints contributions, bug reports, and feature requests are welcome. If you have ideas, just launch you PRs!

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.