Formatters and masks for validating and manipulating user input.
This library uses Simple Translator library for multi lingual support on error messages.
Formatters take user input and return an object. For example if the user entered " 1112223333 " into a currency field. The response would be:
{
errors: [],
formatted: "$1,112,223,333.00",
parsed: 1112223333,
valid: true
}Entering "abc" into a currency field would result in:
{
error: ["FormFormatters.required"],
formatted: "abc",
parsed: "abc",
valid: false
}You might be thinking, but it's a number field how come the result has letters in it? Well the formatters job is to format the text and respond with whether it is valid. The masks job is to mask out values like letters from currency inputs. The mask should run before the formatter.
The mask will return in the the same format as the entry. In other words, it will not return in a complex object.
CurrencyFormatter DateFormatter EmailFormatter HexFormatter NameFormatter NumberFormatter PercentFormatter PhoneFormatter RgbFormatter SsnLastFourFormatter StringFormatter TimeFormatter
CurrencyMask DecimalMask EmailMask HexMask PercentMask PhoneMask SsnMask SsnLastFourMask StringMask TimeMask WholeNumberMask