@jdsalasc/solvejs-validators
v1.8.0
Published
Structured TypeScript validators for forms and APIs with stable error codes, EN/ES/PT UI messages, and phone, postal, password, UUID, IP, URL checks.
Downloads
491
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,validateIsoDateStringtranslateValidationResultfor EN/ES/PT UI messages- Boolean wrappers (
isX) for quick checks
When to use this package
Use it when you need reusable validation rules with explicit error codes and UI-ready messages 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.
Install
npm i @jdsalasc/solvejs-validatorsQuick example
import { validateCellphoneNumber, validateUuidV4, translateValidationResult } from "@jdsalasc/solvejs-validators";
validateCellphoneNumber("+573001234567", { country: "CO" });
validateUuidV4("550e8400-e29b-41d4-a716-446655440000");
translateValidationResult(validateCellphoneNumber("abc"), { locale: "es", fieldLabel: "Telefono" });
// Postal code examples by country:
// validatePostalCode("110111", { country: "CO" });
// validatePostalCode("28013", { country: "ES" });
// validatePostalCode("K1A 0B1", { country: "CA" });
// validatePostalCode("11000", { country: "UY" });