angular-redux / form

Keep your Angular2+ form state in Redux
MIT License
41 stars 15 forks source link

Form validation #38

Closed achobanov closed 6 years ago

achobanov commented 7 years ago

This is a...

What toolchain are you using for transpilation/bundling?

Environment

NodeJS Version: 8.2.1 Typescript Version: 2.3.4 Angular Version: 4.0.0 @angular-redux/store version: 6.5.7 @angular/cli version: 1.2.1 OS: Linux Mint 18.2

Question

How do you implement form validation? I want my required fields to have the have separate validation state, which attaches has-error in bootstrap's form-group class, to showcase the error.

Side node

I believe update on documentation would be good. Following your guide I stumbled upon the "Unexpected keys found in state, received by reducer" warning. I got rid of it by implicitly passing the "unexpected" keys to combineReducers function, with value of (state = {}) => state. That silenced the warning and I think it should be noted in the docs.

smithad15 commented 6 years ago

Sorry for the delay in replying. There are a couple of options available to do form validation. There is nothing stopping you from leveraging Angular's existing form validation tools since the library mainly just syncs the data from your form to a slice of Redux state. There are more advanced ways of doing form validation through the use of state selectors that I have been using recently and will be folding back into this library soon. They require a couple of helper directives, so keep your eyes peeled for that.

I very much agree that documentation requires updating. I'm looking to do a fairly serious overhaul of the library and that is definitely on my hit list. Hope that helps.