-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow throwing on missing control
This adds a configuration option called `shouldThrowOnMissingControl` that checks if the control is not found, if set to a function that returns true. It is set to a function that returns false by default, so this is not breaking change. This allows to catch situations where the controlName has been wrongly specified: ```html <input id="firstName" name="firstName" [(ngModel)]="user.firstName" #firstNameCtrl="ngModel" required/> <!-- the control name mentions lastName whereas the control is firstName --> <val-errors controlName="lastName" id="firstNameErrors"> ``` In that case, if the new option is enabled, valdemort will throw: ``` ngx-valdemort: no control found for controlName: 'lastName'. ``` As the option accepts a function, it can easily be enabled in dev and tests, but disabled in production: ``` config.shouldThrowOnMissingControl = () => !environment.production; ```
- Loading branch information
Showing
3 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters