DEV Community

Discussion on: Input Validation: Client-side or Server-side?

Collapse
 
joelbonetr profile image
JoelBonetR 🥇

Both of course.

You need some filter on client side to avoid sending requests that will lead to failure, then you need validation on server side that match the app logic.

This is because validate things only on client side will make your APP easily hack-able by simply disabling javascript or other techniques.
Apart from that you want to avoid requests that you already know they will return some error because this makes your cloud costs cheaper and on high server load situation you'll get more resource margin.

Given that, I would say that client side validations are meant for giving fast feedback to the user (usability reasons) and for avoiding unnecessary extra requests to the server (economic and performance reasons).

And server side validations are for security reasons.