-
Notifications
You must be signed in to change notification settings - Fork 29.2k
refactor(forms): match getError and hasError to get method signature #20211
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -654,7 +654,7 @@ export abstract class AbstractControl { | |
| * @returns The error data if the control with the given path has the given error, otherwise null | ||
| * or undefined. | ||
| */ | ||
| getError(errorCode: string, path?: string[]): any { | ||
| getError(errorCode: string, path?: Array<string|number>|string): any { | ||
| const control = path ? this.get(path) : this; | ||
| return control && control.errors ? control.errors[errorCode] : null; | ||
| } | ||
|
|
@@ -667,7 +667,9 @@ export abstract class AbstractControl { | |
| * control. | ||
| * @returns True when the control with the given path has the error, otherwise false. | ||
| */ | ||
| hasError(errorCode: string, path?: string[]): boolean { return !!this.getError(errorCode, path); } | ||
| hasError(errorCode: string, path?: Array<string|number>|string): boolean { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you update the type signature on
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh yes, will get on that |
||
| return !!this.getError(errorCode, path); | ||
| } | ||
|
|
||
| /** | ||
| * Retrieves the top-level ancestor of this control. | ||
|
|
||
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.
Why number? Seems odd. And there are no tests as far as I can tell for using numerical arrays.
Uh oh!
There was an error while loading. Please reload this page.
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.
Seams valid if you're traversing through a form array - form arrya being index based.
Ill add some tests.