During my previous question most commenters agreed that getting validation logic both at client &lifier server sides is really a positive thing.

However there's an issue - you have to keep the validation rules synchronized between database and client code.

So now you ask , exactly how should we cope with it ?

One approach is by using ORM techniques, modern ORM tools can produce code that can proper care of data validation prior delivering it towards the server.

I am thinking about hearing your thinking.
Have you got some type of standard process to cope with this issue? Or you believe that this isn't an issue whatsoever? :)

EDIT:

Men, to begin with appreciate your solutions.

Tomorrow I'll summarize you solutions increase question's text as with this case

As pointed out within the solutions towards the other publish, if you are planning and also hardwearing . layers separated, there's not good way of preventing copying the validation logic in every layer. If you are using something to instantly tie them together, you've introduced a kind of coupling between your layers that may hinder you in the future. This can be among individuals cases when you just need to keep an eye on things by hand.

Nevertheless, you do it, you need to make certain each layer does its very own validation, because who knows how that layer will probably be utilized. There is no guarantee that the layers you implemented will invariably stay together.

I love to make use of a validation service, which does not always worry about the foundation from the data to become validated. This can be employed in a couple of various ways when you are getting towards the part about transmitting validation rules to some client (i.e. web site), however i feel the most crucial facet of this really is to possess a single authority for that actual validation rules.

For instance, for those who have validation logic in your data core organizations, like an accumulation of ValidationRule objects which are checked using a Validate method - a really typical scenario, i quickly would promote individuals same rules towards the client (javascript) using a transformation.

Within the ASP.Internet world (the only person I'm able to talk to) you will find a few ways to get this done. My preferred method involves creating custom validators that match for your UI icons to fields (and all sorts of their validation rules) in your organizations. The benefit of this really is that your validation logic could be bundled up right into a single validator. The lower side is your validation messages will end up dense, because the validation rules are examined at the same time. This could, obviously, be mitigated by getting your validation logic return merely a reference to the first failure, etc.

This answer most likely sounds kind of nebulous and unspecific, however the two points that Let me make are:

  1. Validation should take place as near as you possibly can towards the points where information is joined and where it's committed.
  2. Exactly the same validation rules ought to be used wherever validation happens - if client-side validation passes, it should not fail validation afterwards (pre-save business rules, foreign key breach, etc.)

Some framework supplies a validation offer the may keep the client and server validation synchronized. Have a look only at that Seam validation tutorial using annotations. It is a good implementation and incredibly clear to see.

Anyway, if you do not wan't to depend on frameworks, I believe you can easily implement such like.

@Eric I wish to clarify that I am considered myself as somewhat proficient programmer :) I perfectly realize that in some instances (otherwise generally) this duplication is inevitable.

What I wish to listen to community is the greatest practices additional problem.

It is good to understand how people cope with some common problems and adopt best techniques yourself.

For instance you could have some type of defined process explaining steps essential to sync db &lifier code logic.

It may be simple checklist or some software program.

I am thinking about any technique.