ngx-mask icon indicating copy to clipboard operation
ngx-mask copied to clipboard

Mixing optional and mandatory characters in mask doesn't work as expected

Open sgrell opened this issue 8 months ago • 0 comments

🐞 bug report

Description

Mixing optional and mandatory characters in a max, shows inconsistent behaviour.

Everything works if mandatory characters are followed by optional characters. If optional characters come first, than it doesn't work as expected. It does not allow to input only the mandatory characters and does not validate anything.

🔬 Minimal Reproduction

Stackblitz

In this demo I have two input fields, one where I have 3 mandatory letters followed by 3 optional digits. When I start to type letters I will have a validation error because the mask doesn't match, once I typed 3 letters the error is gone, since the digits are optional. As the mask defines I first have to type three letters, every other input is ignored and afterward I can type up to three digits every other input is ignored.

The second input field hast 3 optional digits followed by 3 mandatory letters. I would expect that i can type letters or digits, since the digits are optional, but I can only type digits and only once I have 3 digits I can type letters. I would also expect the same validation errors until I typed 3 letters. But I do not get any validation errors.

🔥 Exception or Error

no exception

🌍 Your Environment

Angular Version:

Angular: 19.2.0 ngx-mask: 19.0.6

sgrell avatar Mar 04 '25 14:03 sgrell