ngx-mask
ngx-mask copied to clipboard
For empty number input mask sets input value as 0 instead of null
Description
When user deletes all digits from number input, input becomes empty but if inspect the input value in console or debugger, its value is actually 0 instead of null. This creates bug when input has required validator which shows that empty input is valid (because it's value is set as 0) whereas it should be invalid.
When I set debugger in writeValue method of input, I see that input value null is transformed into 0 after this._maskService.applyValueChanges call.
🔬 Minimal Reproduction
<input mask="separator.2" [(ngModel)]="value" />
Angular Version:
"ngx-mask": "^11.1.4",
"@angular/cdk": "12.2.3",
"@angular/common": "^12.2.3",
"@angular/compiler": "^12.2.3",
"@angular/core": "^12.2.3",
"@angular/forms": "^12.2.3",
Video of debugger
https://user-images.githubusercontent.com/63780561/165263365-99a66ea1-6e01-40ec-b64d-97d0a74f52fc.mov
+1
hi @dianadomino24 can you please provide all your code for reproducing this issue ?
@xakeppok Hi, I'm a colleague of Diana, I'll ask her to provide minimal reproduction on StackBlitz in coming days
Hey @xakeppok! Sorry for the long reply) Here is the minimal reproduction:
Please, note that when I delete everything from the input, the value is set to 0 instead of null. So I can't distinguish whether user filled in 0 (which is valid) or it's empty input (which is invalid).

@dianadomino24 @zmays Thanks for your using Ngx-Mask. Please update to latest version. It example, all work as expected - https://stackblitz.com/edit/angular-1hp1gb?file=src%2Fmain.ts
In empty text box if I am pressing period key "." its not appearing. I am using ngx-mask: 15.1.0", with angular 15