Mobile App - Input Validation: Client vs Server

Mobile App - Input Validation: Client vs Server

  

hi there,

I am wondering when to do input validation in client action and when to do it in server action? Is there a best practice? Thank you.

regards,

A

There are a few factors to consider. 

Some validations need to be run server-side.

If the app is offline, validation must be done client-side.

A server-side validation means a callback to the server... which can be expensive in terms of a round-trip.

Whatever I can validate client-side... I always do.  Your example of Due Date in the Past is a good one.  You have the test date and current date client-side.  Why make a trip to the server when you have everything you need already.  It's like walking to the store with a loaf of bread in your hand... to get a loaf of bread.

Hi Anonymous,

As Davidk already said, avoid Server Actions on mobile. They slow things down, and don't give you the best user experience. You want to inform the user of wrong input the second they press the submit button (or whatever you have in place).

Solution

Just to add,

While you SHOULD do validation client side, as to improve app performance and user experience, this does not means that you can ignore server side validation, when it comes to do actions that will have impact in the data stored server side.

When saving to server database or synchronyzing, always validate your data and check if the user logged in can do the operation, as the client side can be hacked easily than server side.

Cheers,
Eduardo Jauch

Solution