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

sheet-validator-india-react

v1.0.12

Published

Production-ready React component library for validating Excel/CSV sheets with built-in Indian data validators

Readme

📄 Sheet Validator India - React

A powerful, production-ready React component library for validating Excel/CSV sheets with built-in Indian data validators (Aadhaar, Phone, PIN Code) and custom validation support.

Features

  • ✅ Excel (.xlsx, .xls) and CSV support
  • ✅ Built-in Indian validators (Aadhaar, Phone, PIN Code)
  • ✅ Custom validator functions
  • 3 Styling modes: Default CSS, Tailwind CSS, or Unstyled
  • ✅ Light & Dark theme support
  • ✅ Real-time validation feedback
  • ✅ Detailed error reporting (row, column, value, message)
  • ✅ React Hooks integration
  • ✅ TypeScript support
  • ✅ Accessible UI components
  • ✅ Responsive design
  • ✅ React 16, 17, 18 & 19 support

Installation

npm install sheet-validator-india-react
yarn add sheet-validator-india-react
pnpm add sheet-validator-india-react

Peer Dependencies

{
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
}

Quick Start

import { SheetValidator, VALIDATORS } from 'sheet-validator-india-react';

function App() {
  return (
    <SheetValidator
      validatorConfig={{
        0: VALIDATORS.aadhaar,
        1: VALIDATORS.phone,
        2: VALIDATORS.pinCode,
      }}
      onValidationComplete={(result) => {
        console.log(result);
      }}
    />
  );
}

Styling Options

The component supports 3 styling modes:

1. Default CSS (Auto-injected)

No setup required. Styles are automatically injected.

<SheetValidator styling="default" />

2. Tailwind CSS

For projects using Tailwind. Requires Tailwind CSS configured in your project.

<SheetValidator styling="tailwind" />

3. Unstyled

Bring your own CSS. No styles applied.

<SheetValidator styling="unstyled" />

Full Example

import { SheetValidator, VALIDATORS } from 'sheet-validator-india-react';

function App() {
  return (
    <SheetValidator
      styling="default"
      theme="light"
      title="📄 Sheet Validator"
      subtitle="Upload and validate your CSV or Excel files"
      showPreview={true}
      maxFileSize={5 * 1024 * 1024}
      validatorConfig={{
        0: VALIDATORS.aadhaar,
        1: VALIDATORS.phone,
        2: VALIDATORS.pinCode,
      }}
      columnNames={{
        0: 'Aadhaar Number',
        1: 'Phone Number',
        2: 'PIN Code',
      }}
      onValidationComplete={(result) => {
        if (result.success) {
          console.log('All rows valid!');
        } else {
          console.log(`Found ${result.invalidRows} invalid rows`);
        }
      }}
      onError={(error) => {
        console.error('Error:', error.message);
      }}
    />
  );
}

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | validatorConfig | Record<number, Validator> | required | Column index to validator mapping | | onValidationComplete | (result) => void | required | Callback with validation results | | styling | 'default' \| 'tailwind' \| 'unstyled' | 'default' | Styling mode | | theme | 'light' \| 'dark' | 'light' | Color theme | | title | string | '📄 Sheet Validator' | Component title | | subtitle | string | 'Upload and validate...' | Component subtitle | | columnNames | Record<number, string> | {} | Human-readable column names | | showPreview | boolean | true | Show validation results UI | | maxFileSize | number | 5242880 (5MB) | Max file size in bytes | | onError | (error) => void | undefined | Error callback |


Built-in Validators

| Validator | Format | Example | |-----------|--------|---------| | VALIDATORS.aadhaar | 12 digits, starts with 2-9 | 234567890123 | | VALIDATORS.phone | 10 digits, starts with 6-9 | 9876543210 | | VALIDATORS.pinCode | 6 digits | 110001 |


Custom Validators

Create your own validator function:

const emailValidator = (value: string) => {
  const isValid = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
  return {
    valid: isValid,
    message: isValid ? 'Valid email' : 'Invalid email format',
  };
};

const panValidator = (value: string) => {
  const isValid = /^[A-Z]{5}\d{4}[A-Z]$/.test(value.toUpperCase());
  return {
    valid: isValid,
    message: isValid ? 'Valid PAN' : 'Invalid PAN format (AAAAA9999A)',
  };
};

<SheetValidator
  validatorConfig={{
    0: VALIDATORS.aadhaar,
    1: emailValidator,
    2: panValidator,
  }}
  onValidationComplete={handleResult}
/>

Using the Hook

For custom UI, use the useSheetValidator hook:

import { useSheetValidator, VALIDATORS } from 'sheet-validator-india-react';

function CustomValidator() {
  const { validateFile, loading, progress, result } = useSheetValidator();

  const handleFile = async (file: File) => {
    const result = await validateFile(file, {
      0: VALIDATORS.aadhaar,
      1: VALIDATORS.phone,
    });
    console.log(result);
  };

  return (
    <div>
      <input
        type="file"
        accept=".csv,.xlsx,.xls"
        onChange={(e) => e.target.files?.[0] && handleFile(e.target.files[0])}
        disabled={loading}
      />
      {loading && <p>Processing: {progress}%</p>}
      {result && <p>Found {result.errors.length} errors</p>}
    </div>
  );
}

Validation Result

interface ValidationResult {
  success: boolean;
  message: string;
  totalRows: number;
  invalidRows: number;
  errors: ValidationError[];
}

interface ValidationError {
  row: number;
  column: number;
  value: any;
  error: string;
}

Customizing Default Styles

Override CSS variables to customize the default theme:

:root {
  --sv-primary: #3b82f6;
  --sv-success: #10b981;
  --sv-error: #ef4444;
  --sv-warning: #f59e0b;
  --sv-background: #ffffff;
  --sv-text: #1f2937;
  --sv-border: #e5e7eb;
  --sv-radius: 8px;
}

[data-theme='dark'] {
  --sv-background: #1f2937;
  --sv-text: #f3f4f6;
  --sv-border: #374151;
}

Dark Mode

With Default CSS

<SheetValidator styling="default" theme="dark" />

With Tailwind

Add dark class to your HTML element and use:

<SheetValidator styling="tailwind" theme="dark" />

Browser Support

  • Chrome (latest)
  • Firefox (latest)
  • Safari (latest)
  • Edge (latest)

License

MIT


Contributing

Contributions welcome! Please open an issue or submit a PR.

GitHub: github.com/Rahulskumaroks/sheet-validator-india-react