mercredi 27 mai 2015

How to just keep one copy of list for data validation on both client and server sides

Basically we need to validate data on both client and server sides like many applications. One type of validation is to check if the value is on a LIST or not:

Eg: person_type and id_type must be selected from the list:

  • Person Type List: Student, Teacher, Staff.
  • ID Type List: Driver License, Medicare Card.

So the question is: how to keep these lists identical for both client and server sides.

Now I save these lists on BOTH client and server sides, which means I have to keep two copies in the codebase. Potential solution is loading the value of list from db or cache, but I reckon it's overengineering in this simple case.

Any suggestion?

Thanks.




Aucun commentaire:

Enregistrer un commentaire