@jdsalasc/solvejs-validators
v1.6.0
Published
Zero-dependency JavaScript/TypeScript validators for forms and APIs with structured result codes: phone, postal, username, password, UUID v4, IPv4, and ISO date.
Maintainers
Readme
@jdsalasc/solvejs-validators
Zero-dependency validators for JavaScript and TypeScript forms and API payloads.
Utilities
- Structured validators returning
{ ok, code, message } validateCellphoneNumber,validateEmail,validateHttpUrlvalidateName,validateUsername,validateAddressLine,validatePostalCode(country-aware)validateStrongPassword,validateCreditCardNumbervalidateUuidV4,validateIpv4,validateIsoDateString- Boolean wrappers (
isX) for quick checks
When to use this package
Use it when you need reusable validation rules with explicit error codes instead of plain true/false outputs.
Limitations and Constraints
- Country coverage is explicit and incremental; unsupported countries return structured errors.
- Validators are format-focused and do not verify external authority databases.
- Deprecated typo aliases (
isAddresDirection,isAddresDirrection) remain in1.xfor compatibility and are planned for removal in2.0.0.
Install
npm i @jdsalasc/solvejs-validatorsQuick example
import { validateCellphoneNumber, validateUuidV4 } from "@jdsalasc/solvejs-validators";
validateCellphoneNumber("+573001234567", { country: "CO" });
validateCellphoneNumber("+33612345678", { country: "FR" });
validateUuidV4("550e8400-e29b-41d4-a716-446655440000");
// Postal code examples by country:
// validatePostalCode("110111", { country: "CO" });
// validatePostalCode("28013", { country: "ES" });
// validatePostalCode("K1A 0B1", { country: "CA" });
// validatePostalCode("11000", { country: "UY" });
// validatePostalCode("1012 AB", { country: "NL" });