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

Maskable FormControl is causing `Validators.required` to not function properly

Open bbbneo333 opened this issue 7 years ago • 1 comments

When applying mask on a formControl, the Validators.required validator reports null where it should have returned {required: true} when the control is empty.

I guess the Validators.required prohibits undefined but not null values? Can it be the case where mask is returning null where it should've returned undefined?

  • Control definition:
<input
  [prefix]="phoneNumberPrefix + '-'"
  autocomplete="phone_number"
  class="form-control no-spinner"
  formControlName="phone_number"
  id="phone_number"
  mask="000-000-0000"
  name="phone_number"
  placeholder="{{'FORM_PLACEHOLDERS.USR_CONTACT_NUM' | translate}}"
  type="tel">
  • ngx-mask version - 7.7.0

FYI, I tried without [prefix] but no luck there.

bbbneo333 avatar Mar 21 '19 19:03 bbbneo333

@bbbneo333 Mask validation only works if at least 1 symbol is entered in the input, otherwise the angular's validation will work (if you have connected it)

AlexeyDolya avatar Mar 29 '19 15:03 AlexeyDolya