-
Notifications
You must be signed in to change notification settings - Fork 25.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(forms): implement setErrors #4917
Conversation
*/ | ||
_updateValue() {} | ||
|
||
setErrors(errors: {[key: string]: any}): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add docs? It is easier to do now, then during a big docs push.
Example: var login = new Control("someLogin"); c.setErrors({"notUnique": true}); expect(c.valid).toEqual(false); expect(c.errors).toEqual({"notUnique": true}); c.updateValue("newLogin"); expect(c.valid).toEqual(true); BREAKING CHANGE: Before: ControlGroup.errors and ControlArray.errors returned a reduced value of their children controls' errors. After: ControlGroup.errors and ControlArray.errors return the errors of the group and array. And ControlGroup.controlsErrors and ControlArray.controlsErrors return the reduce value of their children controls' errors.
Merging PR #4917 on behalf of @vsavkin to branch presubmit-vsavkin-pr-4917. |
@@ -364,6 +420,9 @@ export class ControlArray extends AbstractControl { | |||
_updateValue(): void { this._value = this.controls.map((control) => control.value); } | |||
|
|||
/** @internal */ | |||
_calculateControlsErrors() { return Validators.array(this); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it makes sense to move group, and array from Validators? I'm worried that a user might try to pass them in the constructor, or pass them in as a combined validator. Should these functions be used as a regular validator at this point?
LGTM I like it turned out much cleaner than the original design. |
I notice the following things in the source code:
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Example:
BREAKING CHANGE:
Before:
ControlGroup.errors and ControlArray.errors returned the reduced values of their children controls' errors.
After:
ControlGroup.errors and ControlArray.errors return the errors of the group and array.
And ControlGroup.controlsErrors and ControlArray.controlsErrors return the reduce values of their children controls' errors.
Notes: