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

file-validation-engine

v1.0.6

Published

A dynamic rule-based validation engine for Excel and CSV files

Downloads

32

Readme

file-validation-engine

A fast, dynamic rule-based validation engine for Excel and CSV files. Supports custom rules, if/else logic, and efficient chunked processing for millions of rows. Errors are written to a file for review.

System Flow Diagram

[User Provides File Path + Rules]
                |
                v
      [RuleEngine.validateFile]
                |
        +-------+-------+
        |               |
   [CSV File]      [Excel File]
        |               |
 [Stream & Chunk]  [Read & Chunk]
        |               |
        +-------+-------+
                |
        [Validate Each Chunk]
                |
        [Write Errors to File]
                |
        [Return/Notify Completion]

Features

  • Validate Excel (.xlsx, .xls) and CSV files
  • Define custom rules per column, including if/else logic
  • Handles millions of rows efficiently (chunked processing)
  • Errors are written to a file with row numbers
  • Easy to extend and use as an npm package
  • Configurable chunk size for performance tuning

Chunk Size Option

  • The chunkSize option controls how many rows are processed at a time (default: 10,000 rows).
  • You can change this value when creating the RuleEngine instance:
const engine = new RuleEngine(rules, { chunkSize: 5000 }); // processes 5,000 rows per chunk
  • Adjust chunkSize based on your available memory and file size for optimal performance.

Usage

  1. Define your rules as an array of objects specifying the column, type, validation options, custom validation, error message, and optional condition. Example:
const ruleConfigs = [
  { column: 'id', type: 'integer', nullable: false },
  { column: 'price', type: 'number', maxDecimals: 3, nullable: true },
  { column: 'name', type: 'string', max: 20, nullable: false, allowEmpty: false },
  { column: 'description', type: 'string', nullable: true, allowEmpty: true },
  { column: 'email', type: 'string', allowEmpty: true, customValidate: value => /.+@.+\..+/.test(value), errorMessage: 'must be a valid email format', condition: row => row['email'] !== '' },
  { column: 'status', type: 'string', customValidate: (value, row) => value === 'active' || row['age'] > 18, errorMessage: 'must be active if age > 18' },
];
  1. Create rules using a helper (optional):
const rules = ruleConfigs.map(makeRule);
  1. Create a RuleEngine instance and validate your file:
const engine = new RuleEngine(rules, { chunkSize: 5000 });
const inputFile = 'input.csv';
const errorFile = 'validation_error.txt';
await engine.validateFile(inputFile, errorFile);

See lib/example.js for a sample usage.

Install

npm install file-validation-engine

License

MIT