JsDaddy / ngx-mask

Angular Plugin to make masks on form fields and html elements.
https://jsdaddy.github.io/ngx-mask
MIT License
1.14k stars 298 forks source link

Token for static pre-defined masks (like CPF_CNPJ) #1376

Open GLugano opened 1 week ago

GLugano commented 1 week ago

🚀 feature request

Description

While making a new project, im trying to make things more "default" in the project and tried (without success) to create default patterns that i could reuse between components.

Describe the solution you'd like

By using the angular tokens, its possible to configure patterns to be used in whole app.

Taking CPF_CNPJ for example, it is translated to a mask that depends on the length, but i wanted just CPF or CNPJ and i didn't want to write everytime time those masks.

By providing a token with a key and value, would be possible to verify at position near the code from CPF_CNPJ all the values inside the token (token would be a array or an object) and check if the maskExpression is equal to one of the values and then swap the value with the mask provided. Would be literally swapping the string, nothing crazy and could be configured in the root of the app.

And for other similar situations for different countries, would be easier for people to not be dependent on updates here (as CPF_CNPJ is a brazilian thing, imagine making it for every specific country) and would have freedom to make their own static masks.

I could do it myself, but i have no knowledge about helping packages. :/

Describe alternatives you've considered

Couldn't find any possible ways add.