Repository navigation
FormaJS v1.1.0: Introducing new Formatters and Massive Optimization
We are excited to announce version 1.1.0! This is the first major update since the v1.0 launch and focuses on two key areas: expanding the library beyond validation by introducing a new and powerful Formatters category, and a drastic optimization of the package size.
The library's unpacked size has been reduced from 1.34 MB to 454.1 kB (a ~66% reduction)! This makes the library much lighter and faster for all users in production.
🚀 New Formatters (formatters/)
They are the "inverse" of our validators and parsers, using internationalization (i18n) rules to format data cleanly.
formatCurrency: Converts a number (e.g.,1234.50) into a locale-aware currency string (e.g., "R$ 1.234,56" or "$1,234.50").formatDate: Converts aDateobject into a formatted string (e.g., "31/10/2025") using the newmasks.daterule from i18n.formatPostalCode: Formats ZIP/Postal code digits (e.g., "01001000") into the locale's mask (e.g., "01001-000").formatMobileNumber: Formats mobile number digits using thelocalorinternationalmasks (e.g., "+55 (11) 98765-4321").formatTaxId: Formats a Tax ID (CPF, CNPJ, SSN) using theoption.typeto select the correct mask (e.g., "###.###.###-##").
📐 Architectural Improvements (Formatter Support)
To make the formatters possible without hardcoding logic:
- The locale files (e.g.,
pt-BR.jsonanden-US.json) now contain a centralizedmasksobject, which defines the formats forpostalcode,mobileNumber,date, andtaxId. - The
applyFormatMaskutility was added to apply format masks consistently.
🛠️ New Sanitizers
- Added the
padStartandpadEndsanitizers. They are essential utilities, perfect for preparing data before formatting (e.g., adding leading zeros to a CPF before callingformatTaxId).
This release completes the planned feature set for v1.x. The next step will be the evolution to v2.0, focusing on schema validation (chaining)!
Full Changelog: v1.0.0...v1.1.0