views:

20

answers:

2

Hi,

I have an application that must be prepared to work in various companies. But I fear that every company needs specific validation rule. What is the better way to perform validation in my presentation layer without having to recompile my application for each client?

+1  A: 

I recently had to do something similar to this.

What I went with was the use of XML template files and defined a schema for the files. In my validation routine(s) I iterate over all of the criteria XML nodes and using the information in them I perform the validation. This allows for me to redefine the XML file at any time and it will work with my application (as long as it stays within the defined schema).

Tony Abrams
Thanks for your reply. how do you load the xml data to application? Using object serialization?
reikara
For my applications needs, I just have the XML files as flat files in a sub-directory of the application. I didn't feel the need to add the validation XML as a database dependency, but you could store them in a database if desired.
Tony Abrams
A: 

Keep the validation rules out of source code and store them in a database or external file instead.

The source code should read the rules to apply from the external source and derive its behavior from there.

It's even better if the users can modify the rules themselves.

Beth