Ask HN: What is the best way to verify forms
E.g. it's easier for the user to enter a list of IP addresses separated by commas, but your data structure holds an array of IP addresses. If the user enters invalid data, this must be shown in the GUI as an error.
And anytime the user modifies something, the data structures have to be modified (or not, depending on whether you decide to save automatically or have a 'save' button) and certain parts of your GUI have to be updated, too.
Usually when I start writing something like this, it becomes incredibly complex code.
What is the best concept to handle serialize and de-serialize user input in a GUI? Any good videos of talks about this?
I am not looking for a specific library in JS, C++ or what ever, but rather for a concept/programming pattern/whatever to deal with this situation.
1 comment
[ 2.9 ms ] story [ 15.4 ms ] threadYou either make it more structured and need less validations and transforms or you make it more free form and need more validations and transforms. And it depends on the case. In the end, you probably want to construct some JSON that maps to part or all of your data structure. Depending on how important it is to get the data "right," you can also prompt the user with a "does this look right?" confirmation. Also, don't forget all the "falsehoods programmers believe about" articles.