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

regulated-form-validator

v1.0.3

Published

Declarative, compliance-ready form validation for React with YAML/JSON configs and runtime custom rules.

Readme

📦 Regulated Form Validator (React)

Regulated Form Validator is a React library for compliance‑ready form validation and rendering, powered by YAML/JSON declarative configs.
It helps developers build dynamic, auditor‑friendly forms for BFSI, healthcare, and other regulated domains without reinventing validation logic.

  • 🛡️ Compliance‑focused: Ships with BFSI & healthcare presets (PAN, Aadhaar, IFSC, Insurance IDs, etc.)
  • Developer‑friendly: Declarative configs, runtime custom rule registry, reusable preset fields, async API validation
  • 🌍 i18n‑ready: Localized error messages (en, fr, etc.) for multilingual compliance workflows
  • 👀 Audit‑ready: Human‑readable configs that make validation logic transparent for compliance reviews
  • 🔄 Runtime flexibility: Add, remove, or list custom rules dynamically without redeploying
  • 🧩 Error‑safe architecture: Regex, date, async, and conditional rules handle invalid inputs gracefully

This project bridges the gap between developer productivity and regulatory compliance, making it easy to build forms that are both user‑friendly, multilingual, and audit‑ready.

✨ Features

Declarative config: Define fields and rules in YAML/JSON.
Dynamic rendering: Auto-generate React forms from config.
Rich validations: required, regex, length, enum, number, date, crossField, conditional(when), async, custom, i18n.
BFSI rules built-in: PAN, IFSC, Aadhaar.
Auditor-friendly: Human-readable config files for compliance reviews.
Error‑safe: Regex, date, async, and conditional rules handle invalid inputs gracefully.
Custom registry API: Add, remove, and list custom rules at runtime.
i18n support: Localized error messages (en, fr, etc.) for multilingual compliance workflows.

📥 Installation

npm install regulated-form-validator

📋 Preset Fields

The library ships with ready‑to‑use preset fields for daily‑use, BFSI, and healthcare domains. Each preset includes strict validations, per‑character filtering (allowedChars), and immediate error feedback (messageOnInvalid).

⚡ Quick Example: Load Presets in React Here’s how developers can directly use preset fields without writing YAML:

import {
  FormRenderer,
  validateAll,
  NameField,
  EmailField,
  PANField,
} from "regulated-form-validator";

export default function PresetDemo() {
  const presetConfig = {
    fields: [NameField, EmailField, PANField],
  };

  return (
    <FormRenderer
      config={presetConfig}
      onSubmit={(values) => {
        const result = validateAll(presetConfig.fields, values);
        console.log("Validation Result:", result);
      }}
    />
  );
}

🏠 Daily-Use Preset Fields

The library ships with strict daily-use presets for common scenarios:

  • NameField – required, alphabets only, 2–50 characters
  • PincodeField – required, exactly 6 digits
  • EmailField – required, proper email format
  • AddressField – required, alphanumeric + space/comma/dot/hyphen, 5–100 characters
  • PhoneField – required, exactly 10 digits
  • GenderField – required select (Male, Female, Other)
  • PasswordField – required, strong password (≥8 chars, uppercase, lowercase, number, special char)
  • ConfirmPasswordField – required, must match PasswordField
  • DobField – required, valid date, must be before today
  • UsernameField – required, 5–20 chars, alphanumeric + underscore
  • OTPField – required, exactly 6 digits
  • AlternateEmailField – optional, valid email format
  • AlternatePhoneField – optional, valid 10-digit phone number
  • AgeField – required, number between 18 and 65

Each preset includes:

  • allowedChars for per-character filtering
  • messageOnInvalid for immediate feedback
  • Human-readable error messages for compliance reviews

🏦 BFSI Preset Fields

The library ships with strict BFSI presets for compliance‑heavy domains:

  • IFSCField – required, 11 characters, format SBIN0001234
  • GSTField – required, exactly 15 characters, strict GSTIN format
  • AccountNumberField – required, 9–18 digits
  • MICRField – required, exactly 9 digits
  • SWIFTField – required, 8 or 11 alphanumeric characters
  • CreditCardField – required, exactly 16 digits
  • CVVField – required, exactly 3 digits (password type)
  • ExpiryDateField – required, valid future date in MM/YY format

Each preset includes:

  • Uppercase enforcement where applicable
  • allowedChars for per‑character filtering
  • messageOnInvalid for immediate feedback
  • Auditor‑friendly error messages
  • Enhanced validations for BFSI compliance (length, regex, conditional checks)

🏥 Healthcare Preset Fields

The library ships with strict healthcare presets for patient and medical record management:

  • PatientIDField – required, exactly 8 characters, uppercase letters + digits
  • InsuranceField – required, 2 uppercase letters + 6 digits (e.g., AB123456)
  • HealthIDField – required, 10–16 characters, uppercase letters + digits
  • BloodGroupField – required select, options: A+, A-, B+, B-, O+, O-, AB+, AB-
  • MedicalRecordField – required, 6–12 digits
  • DoctorIDField – required, exactly 6 characters, uppercase letters + digits
  • HospitalCodeField – required, 3 uppercase letters + 3 digits (e.g., HSP123)
  • PrescriptionIDField – required, exactly 10 digits
  • NationalHealthNumberField (NHN) – required, exactly 12 digits

Each preset includes:

  • Uppercase enforcement where applicable
  • allowedChars for per‑character filtering
  • messageOnInvalid for immediate feedback
  • Auditor‑friendly error messages
  • Enhanced validations for healthcare compliance (length, regex, select options, conditional checks)

🏛 Government ID Preset Fields

The library also ships with strict Government ID presets for compliance‑heavy domains:

  • PANField – required, 10 characters, format ABCDE1234F
  • AadhaarField – required, exactly 12 digits
  • VoterIDField – required, exactly 10 alphanumeric characters
  • DrivingLicenseField – required, exactly 16 alphanumeric characters
  • PassportField – required, 8 characters, format A1234567 (1 uppercase letter + 7 digits)

Each preset includes:

  • Uppercase enforcement where applicable
  • allowedChars for per‑character filtering
  • messageOnInvalid for immediate feedback
  • Auditor‑friendly error messages
  • Enhanced validations for government compliance (length, regex, uppercase enforcement)

💡 Usage Note:
For practical examples of how to import and use these preset fields in a React app,
please refer to example/Demo.jsx.
This demo shows how to configure forms, override preset validations, and integrate
advanced rules (crossField, conditional when, async, i18n).

📖 Yaml Usage

  1. Define a YAML Config for Customization
fields:
  - name: fullName
    label: Full Name
    type: text
    validation:
      - type: required
        message: "Full name is required"
      - type: regex
        pattern: "^[A-Za-z ]+$"
        message: "Only letters and spaces"
      - type: length
        min: 3
        message: "At least 3 characters"

  - name: pan
    label: PAN
    type: text
    validation:
      - type: required
        message: "PAN is required"
      - type: pan
        message: "Invalid PAN"
  1. Load and Render in React
import React from "react";
import { parseConfig, FormRenderer, validateAll } from "regulated-form-validator";
import yaml from "js-yaml";
import fs from "fs";

const config = parseConfig("form-config.yaml");

export default function App() {
  return (
    <FormRenderer
      config={config}
      onSubmit={(values) => {
        const result = validateAll(config.fields, values);
        console.log(result);
      }}
    />
  );
}

🔧 Customization

You can customize fields in several ways:

  1. Override presets
import { NameField } from "regulated-form-validator";

const CustomNameField = {
  ...NameField,
  label: "Applicant Name",
  validation: [
    ...NameField.validation,
    { type: "regex", pattern: "^[A-Za-z]+$", message: "No spaces allowed" }
  ]
};
  1. Add allowedChars and messageOnInvalid
const NumericCodeField = {
  name: "code",
  label: "Numeric Code",
  type: "text",
  validation: [{ type: "required", message: "Code is required" }],
  allowedChars: /^[0-9]$/,
  messageOnInvalid: "Only digits are allowed"
};
  1. Custom rules via addCustom
addCustom("startsWithA", (value) => String(value ?? "").startsWith("A"));

🧪 Testing

Run unit tests locally to validate your form logic:

# Run all tests
npm test

# Run tests in watch mode (helpful during development)
npm run test:watch

Tests are located in the directory and cover:
• Field rendering from YAML/JSON configs
• Built-in BFSI validations (PAN, IFSC, Aadhaar)
• Conditional and cross-field rules
• Custom validation hooks • Error handling for invalid regex/date inputs • Runtime registry API (addCustom, removeCustom, listCustom)

📜 License

MIT © 2026 Abhiraj Madan Marne

💡 Roadmap

• ✅ Local demo app for testing
• ✅ Publish to npm registry
• ✅ Add more domain-specific validation rules
• ✅ Expand documentation with examples • 🚧 Add Responsive CSS

🤝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to open a PR or start a discussion in the issues section.

🌟 Why This Matters

This project aims to make regulated form validation simple, declarative, and auditor-friendly. By using YAML/JSON configs, developers can build compliance-ready forms without reinventing validation logic for BFSI, healthcare, and other sensitive domains.