ngx-formly
ngx-formly copied to clipboard
feat(core): add showValid configuration extra
THIS IS A DRAFT PR
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
This is a feature to add a centrally configurable showValid extra that types and wrappers can read to configure their validation display behavior.
What is the current behavior? (You can also link to an open issue here)
Currently, it is possible to configure when to show errors using showError. This is sometimes too limited as explained in #2728.
What is the new behavior (if this is a feature change)?
Now, an additional function (showValid) is available to separately control when to show valid feedback (positive validation) messages and styling. This is not used throughout formly itself but e.g. bootstraps supports it and it is very useful to have a configurable analogue in the module
@aitboudad this is what I had in mind, it's a pretty small change in the core functionality. The custom type in the provided example is adjusted to show what I mean. Of course, this is a draft PR so if you still think this is a useful feature (even though it doesn't address your concerns about #2385 ) I will proceed and flesh it out with tests and see how to fix the change detection in the example. I'm also willing to work on a more general solution and probably more complex solution for more fine-grained control over validation. In that case just reject this PR and we can discuss how to proceed.
Please check if the PR fulfills these requirements
- [ ] The commit messages follow our guidelines: https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#commit-message-format
- [ ] A unit test has been written for this change.
- [ ] Running
npm run buildproduced a successful build. (Unit testing can be done by runningnpm test;) - [ ] My code has been linted. (
npm run lintto do this.npm run buildwill fail if there are files not linted.)
Please provide a screenshot of this feature before and after your code changes, if applicable.
Other information:
Deploy Preview for formly-dev failed.
| Name | Link |
|---|---|
| Latest commit | b0d60d2f7a5b9882ce4f151a00e29980f5183842 |
| Latest deploy log | https://app.netlify.com/sites/formly-dev/deploys/62e12d65665f820008bca26f |
Thanks for the PR :+1:, I may see if we can unify the current approach with some related issues else we can go that way!
Okay great, let me know how I can help :) I'm ready to do some actual coding in here!