| ▲ | skybrian 4 hours ago | |||||||
What do people like for form validation? In this article he recommends the “validation-enhancer” library: https://www.npmjs.com/package/validation-enhancer I’ve also seen one called “formisch” that the author of valibot is working on: https://github.com/open-circle/formisch They’re both pretty new. Has anyone tried them? | ||||||||
| ▲ | kccqzy 3 hours ago | parent [-] | |||||||
My biggest tip to reduce complexity of data validation if you are using React is to stop using React controlled components and switch to React uncontrolled components. They are an underused part of React. You usually don’t need React to handle every single keypress and every single character being entered by the user. In fact before React popularized it, it was unusual for form components to update on each key press; traditional desktop apps tend to validate when a field loses focus only, not on each key press. This has at least three benefits: (a) good for performance, (b) reduces unnecessary error UI when the user is in the middle of entering data, and (c) simplifies your own code by not having to deal with prefixes of valid input that’s not itself valid. | ||||||||
| ||||||||