Feature - Add global error message support #1054
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds global message support, similar to functionality provided by ngx-formly.
The goals of this PR are as follows.
.
Example Usage:
For the moment some additional "gymnastics" is required in order to get the controls to render the messages. See an example of that below.
//form.component.ts
The model definition still requires that we "opt-in" to error messages.
The result will be a control which shows the "catch-all" error message received from the server.
Room for improvements.
Use Cases:
Given that I am defining multiple forms
When I configure the validation rules
Then I should not have to repeat the errorMessages for each input in order for the messages to display on the control.
Given that I am defining a form
When I configure the validation rules
Then I should be able to process the error via a callback before returning the error message.
Given that I submit a form to the server
When the server returns a 422 response code with validation errors mapped to attribute name
Then show the error contextually on the form.