Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keeping validation logic in sync between server and client sides [closed]

In my previous question, most commenters agreed that having validation logic both at client & server sides is a good thing.

However there is a problem - you need to keep your validation rules in sync between database and client code.

So the question is, how can we deal with it?

One approach is to use ORM techniques, modern ORM tools can produce code that can take care of data validation prior sending it to the server.

I'm interested in hearing your opinions.

Do you have some kind of standard process to deal with this problem? Or maybe you think that this is not a problem at all?


EDIT

Guys, first of all thank you for your answers.

Tomorrow I will sum up you answers and update question's text like in this case.

like image 250
aku Avatar asked Sep 02 '08 14:09

aku


1 Answers

As mentioned in one of the answers to the other post, if you are going to keep your layers separated, there is no good way to avoid duplicating the validation logic in each layer. If you use something to automatically tie them together, you have introduced a sort of coupling between the layers that might hinder you down the road. This might be one of those cases where you just have to keep track of things manually.

However you go about it, you have to make sure each layer is doing its own validation, because you never know how that layer is going to be accessed. There's no guarantee that all the layers you implemented will always stay together.

like image 158
Eric Z Beard Avatar answered Nov 11 '22 21:11

Eric Z Beard