Format
The built-in format plugin — apply input masks on change or blur
Format
The format field config is powered by the built-in formatPlugin — see Formatters for the full list of built-in formatters.
Usage
validationSchema: {
ssn: { format: "ssn" }, // 123-45-6789
phone: { format: { type: "phone", options: { country: "IN", ext: false } } },
name: { format: [{ type: "trim", trigger: "onBlur", options: { mode: "both" } }, "upperCase"] },
}Each entry accepts { type, trigger?, options? } — trigger is "onChange" (default) or "onBlur", or both via two steps.
Things to know
- Formatting runs before validation, so errors always match what the user sees.
- Values are also formatted on submit, so
onSubmitreceives clean data. - Pass a plugin named
"format"to override the built-in behavior.