I have a requirement that certain input fields need to be masked. Example, desired amount should be displayed as $44,444. I can achieve the input masking by using text-mask (https://github.com/text-mask/text-mask). The problem I am encountering is that the masking breaks my reactive form validators.
component:
import {WithinLoanRangeDirective} from './within-loan-range.directive'
this.applicationForm = this.fb.group({
desiredAmount: ['', [Validators.required, WithinLoanRangeDirective] ]
})
template:
<input
[textMask]="{mask: numberMask}"
mdInput
formControlName="desiredLoanAmount
type="tel"
> <!--type tel to pop numpad-->
<div> {{ applicationForm.controls['desiredLoanAmount'].hasError('withinLoanAmountRange')}}</div>
The validators are now checking min and max against the masked input ($44,444) instead of (44444). Is there a way to format the value before setting it in model?