Let's say that I have this form structure:
this.entryForm = this.formBuilder.group({
date: [{value:'' , disabled: true}, [Validators.required]],
notes: [''],
sum_credit: [{value:'', disabled: true }],
sum_debit: [{value:'', disabled: true}],
items: this.initItems()
});
// set validation function to sum_credit
this.entryForm.controls['sum_credit'].setValidators([CommonValidations.validateSomthing(...)]);
The sum_credit is disabled because it's value is always calculated.
Now I need to validate that the sum_credit is equaled to sum_debit, and I'm already doing that using validateSomthing function.
The problem is that the validateSomthing is not triggered because the control is disabled. How can I fix that?
Thanks
sum_creditis "always calculated", why do you even need to have a validator for it? Feels like you should have a unit (or integration) test instead.sum_creditshouldn't even be into the form. And when you handle the submit and pass the object, just add the computation of that field.