getError method
Returns the error data for the control with the given errorCode in the
given path.
If no path is given, this method checks for the error on the current
control.
Example:
final form = FormGroup({
'payment': FormGroup({
'amount': FormControl<double>(
value: 5.0,
validators: [Validators.min(10.0)]
),
}),
});
final error = form.getError(ValidationMessages.min, 'payment.amount');
print(error); // outputs: { min: 10.0, actual: 5.0 }
Implementation
Object? getError(String errorCode, [String? path]) {
final control = path != null ? findControl(path) : this;
return control!.errors[errorCode];
}