validators

Validators

A collection of minimal, dependency-free, small input-validation helpers for modern web and edge environments.

Overview

Validators provides standalone, auditable modules with no runtime dependencies. Each module focuses on a single responsibility and avoids risky features such as eval, regex backtracking, or URL parsing ambiguities.

Available modules:

All helpers are designed for use in:

Each module can be imported individually; browser demo pages and a Node regression suite are included.

🔗 Live Demos (GitHub Pages)

You can try each validator interactively in your browser:

Each page loads its respective module and allows interactive validation.

Use

Import the individual ESM files directly. This repository does not require a package installation or build step.

Run regression tests with Node.js 22 or newer:

node --experimental-default-type=module --test tests/*.test.mjs

Benchmark/gzip badge refreshes are manual; correctness tests remain automatic on PRs and pushes.

API behavior

Design Principles

  1. Safety first: Reject malformed or ambiguous inputs by default.
  2. No dependencies: Avoids third-party packages that may introduce vulnerabilities.
  3. Auditable simplicity: Clear logic under 150 lines per module.
  4. Portability: Works across environments without build tools.
  5. Transparency: Open source with no hidden telemetry or build steps.

Example usage

import { validateCard } from './is-card-safe/card.js';
import { isIsoDateSafe } from './is-iso-date-safe/date.js';
import { isUuidSafe } from './is-uuid-safe/uuid.js';
import { isIpSafe } from './is-ip-safe/ip.js';
import { isJsonSafe } from './is-json-safe/json.js';
import { isIbanSafe } from './is-iban-safe/iban.js';
import { validateTIN } from './is-us-tin-safe/tin.js';

console.log(validateCard('4111 1111 1111 1111').ok); // true
console.log(isIsoDateSafe('2024-02-29'));              // true
console.log(isUuidSafe('550e8400-e29b-41d4-a716-446655440000', { version: 4 })); // true
console.log(isIpSafe('2001:db8::1'));                 // { ok: true, version: 6, issues: [] }
console.log(isJsonSafe('{"id":1}').ok);                // true
console.log((await isIbanSafe('DE44500105175407324931')).ok); // true
console.log(validateTIN('12-3456789').type);         // 'ein'

Folder Structure

validators/
  ├─ .github/
  │   └─ FUNDING.yml
  ├─ LICENSE
  ├─ README.md
  ├─ SECURITY.md
  ├─ is-card-safe/
  ├─ is-email-safe/
  ├─ is-iban-safe/
  ├─ is-iso-date-safe/
  ├─ is-ip-safe/
  ├─ is-json-safe/
  ├─ is-password-safe/
  ├─ is-phone-e164/
  ├─ is-uuid-safe/
  ├─ is-url-safe/
  ├─ is-us-tin-safe/
  └─ is-vat-safe/

Security Notes

Contributing

Pull requests for additional safe validators (e.g., IBAN, domain names, etc.) are welcome. Please maintain the following rules:

License

Licensed under the MIT License — see LICENSE.

Funding

If you find this project useful, please consider sponsoring its continued maintenance and security audits.

You can sponsor this project through:


© 2025 Y Consulting LLC / Validators Project