3 ms·
Not sure I agree with the idea that you should validate only on the backend, I think you should do both. Backend validation is for you, to ensure that the data
by Etheryte 2y ago
Not sure I agree with the idea that you should validate only on the backend, I think you should do both. Backend validation is for you, to ensure that the data is valid and sane, frontend validation is for the user, so they can get early feedback if something is wrong.
- globular-toast 2y agoYou can do basic validation on the frontend. The problem is if you do too much you end up with two sets of, possibly subtly different, rules that you need to maintain.
- tgv 2y agoIn many cases, that's better than having it done only on the backend, because it would confuse (and anger) users. "It knows this isn't correct, why does it let me do it and then say 422 SCNUKS"?
- whiterknight 2y agoYou don’t return readable errors from backend to user? You don’t wait for requests to confirm before assuming they do?
- ongy 2y agoFor something like input field validation, a request per keystroke might be a bit much, but the update rate of feedback users expect. In systems with frontend UX validation and backend functional validation, errors from the backend tend to be aimed at devs. I.e. might expose the reflex that's known good over having nice words for the approximate test done in the frontend.
- tgv 2y agoThen the code duplication problem moves to the back-end. And it's not the best place for readable error messages.