feat: support showing errors when a control is marked as touched
PR Checklist
Please check if your PR fulfills the following requirements:
- [x] The commit message follows our guidelines: CONTRIBUTING.md#commit
- [x] Tests for the changes have been added (for bug fixes / features)
- [x] Docs have been added / updated (for bug fixes / features)
PR Type
What kind of change does this PR introduce?
[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:
What is the current behavior?
Issue Number: https://github.com/ngneat/error-tailor/issues/64
Currently errors are not shown if a control is marked as touched programmatically via control.markAsTouched() or formGroup.markAllAsTouched().
What is the new behavior?
When setting controlErrorsOn: { touched: true } in the config or when setting the [controlErrorsOnTouched]="true" input on a form control, errors will be show when the control is marked as touched (control.touched === true) and will be hidden if the control becomes pristine again after being touched.
Does this PR introduce a breaking change?
[ ] Yes
[x] No
Run & review this pull request in StackBlitz Codeflow.
@NetanelBasal Looking forward to know your thoughts.
Took it a step further and since configs to change the default behavior are a few now, I thought it would be good to explain a bit better how it works, so I added a Customize the behavior section in the README.md, let me know what you think.