Carlos Cifuentes
AngularJS library migration · input masks

Migrating ui-mask / angular-input-masks to modern Angular

ui-mask applied a pattern such as (999) 999-9999 to an input, and angular-input-masks added ready-made masks for money, dates and Brazilian documents such as CPF and CNPJ. Both are tied to AngularJS.

What replaces it

OptionWhen to choose it
ngx-maskClosest match to ui-mask: a mask directive with pattern strings, plus a pipe for display.
Maskito (@maskito/angular)Framework-agnostic masking library with an Angular package; good for number, date and custom masks.
Native input attributes + validatorsWhen the mask only limited length or characters: inputmode, maxlength and a validator are enough.

How to migrate it

  1. List every mask pattern in use and whether the model stores the raw value or the formatted one.
  2. Define the patterns once, in a shared directive or constants file, so each form does not repeat them.
  3. Replace the masks screen by screen and test typing, pasting, autofill and backspace on each one.

Watch out. ui-mask stores the unmasked value in the model by default. Confirm what the new library writes to the form control, because the backend receives exactly that.

Other libraries

Planning a migration or a micro-frontend platform?

In a 20-minute call you describe your situation and I tell you how I'd approach it. If it isn't worth doing yet, I'll say so.

Message me on LinkedIn