A collection of minimal, dependency-free, small input-validation helpers for modern web and edge environments.
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:
-
is-card-safe — Credit card validator with Luhn check and brand detection (Visa, Mastercard, Amex, etc.).
-
is-email-safe — Strict RFC-like ASCII email validation, no external dependencies.
-
is-iban-safe — ISO 13616 / ISO 7064 IBAN validator powered by the official SWIFT registry.
-
is-iso-date-safe — Strict Gregorian YYYY-MM-DD validation, including leap years. Module
-
is-ip-safe — IPv4 and IPv6 address validator with normalization and compression-safe parsing.
-
is-json-safe — JSON structure validator and sanitizer that enforces depth, size, and key limits.
-
is-password-safe — Password strength and safety validator (entropy, sequences, dictionary words, and repetition checks).
-
is-phone-e164 — E.164 international phone number validator with normalization.
-
is-uuid-safe — Canonical UUID validation with optional version checking (v1–v8, including v4/v7). Module
-
is-url-safe — Conservative
http(s)-only URL validator resistant to bypass attacks.
-
is-us-tin-safe — Validates U.S. Taxpayer Identification Numbers (EIN, SSN, ITIN).
-
is-vat-safe — EU VAT ID pattern validator for all member states (format-only, no checksum).
All helpers are designed for use in:
- Browsers (ESM)
- Node.js / Deno / Bun (import)
- Edge runtimes (Cloudflare Workers, Vercel Edge, etc.)
Each module can be imported individually; browser demo pages and a Node regression suite are included.
You can try each validator interactively in your browser:
- Card Validator Test
- Email Validator Test
- IBAN Validator Test
- ISO Date Validator Test
- IP Validator Test
- JSON Validator Test
- Password Validator Test
- Phone Validator Test
- UUID Validator Test
- URL Validator Test
- US TIN Validator Test
- EU VAT Validator Test
Each page loads its respective module and allows interactive validation.
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.mjsBenchmark/gzip badge refreshes are manual; correctness tests remain automatic on PRs and pushes.
isIpSafe(),isJsonSafe(),validateCard(), andvalidateTIN()return result objects, not booleans. Use theirokproperties.isIbanSafe()returns a Promise and readsis-iban-safe/iban_registry_full.json. Keep the JSON file next toiban.js.- JSON
maxBytesmeasures UTF-8 bytes and rejects oversized input before parsing. Other structural checks happen afterJSON.parse. isIsoDateSafe()andisUuidSafe()return booleans and enforce canonical date/UUID syntax.- Card, TIN, VAT, email, and phone checks validate local format rules only; they do not verify real-world issuance or ownership.
- Safety first: Reject malformed or ambiguous inputs by default.
- No dependencies: Avoids third-party packages that may introduce vulnerabilities.
- Auditable simplicity: Clear logic under 150 lines per module.
- Portability: Works across environments without build tools.
- Transparency: Open source with no hidden telemetry or build steps.
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'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/
- Regular expressions are simple and should still be regression-tested with untrusted inputs.
- No dynamic code execution or eval-like patterns are used.
- URL validation permits only
httpandhttps; do not treat this as a network-access or SSRF policy. - Emails and phones are validated according to conservative subsets of relevant RFCs and ITU standards.
Pull requests for additional safe validators (e.g., IBAN, domain names, etc.) are welcome. Please maintain the following rules:
- Pure functions only (no side effects)
- No external dependencies
- Regression tests for changed behavior
- TypeScript or plain ESM JavaScript
Licensed under the MIT License — see LICENSE.
If you find this project useful, please consider sponsoring its continued maintenance and security audits.
You can sponsor this project through:
- GitHub Sponsors: https://github.com/sponsors/yvancg
- Or any link listed in
.github/FUNDING.yml
© 2025 Y Consulting LLC / Validators Project