ngx-mask
ngx-mask copied to clipboard
Mixing optional and mandatory characters in mask doesn't work as expected
🐞 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
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