void setErrors(Map<String, dynamic> errors, { bool emitEvent })

Sets errors on a control.

This is used when validations are run not automatically, but manually by the user.

Calling setErrors will also update the validity of the parent control.

Usage

Control login = new Control("someLogin");
login.setErrors({
  "notUnique": true
});
 
expect(login.valid).toEqual(false);
expect(login.errors).toEqual({"notUnique": true});
 
login.updateValue("someOtherLogin");
 
expect(login.valid).toEqual(true);

Source

void setErrors(Map<String, dynamic> errors, {bool emitEvent}) {
  emitEvent = emitEvent ?? true;
  this._errors = errors;
  this._status = this._calculateStatus();
  if (emitEvent) {
    this._statusChanges.add(this._status);
  }
  _parent?._updateControlsErrors();
}