May 31, 2007 at 4:48 PM
Edited May 31, 2007 at 5:30 PM
I need to do some pretty complex validation on my project and would like to get input from you if it's doable in the EntLib.
First about task. I work for an insurance company, hence the object structure...
Policy -> Endorsements -> Endorsement -> Drivers -> Driver
|-> Vehicles -> Vehicle
Simplified of course...
Now imagine that I have more then one US state in service.
My idea was to create kind of layered validation.
First layer is entity fields validation
Second is logic common for all US states
Third is logic specific for a particular US state.
Every layer will be presented as rule set on object type.
Once I need validate policy I need to combine all three sets together in a single validator. Kind of chain of responsibility. Once we have it build we can use it multiple times.
I need to write factory class which will take policy object as parameter and do following
1. Create entity validator for policy record.
2. Create AllStates validator for policy record
3. Create policy record validator for a specific state.
4. Check if we have endorsements and if so,
5. Create entity validator for endorsement
6. Create AllStates validator for endorsement
7. Create state specific validator for endorsement
8. Check if we have drivers and do same for drivers
9. Check vehicles and do same for vehicles.
As you see sometimes I need conditional validation based on values of one or more properties.
Is there any way to implement such conditional validator? I guess that it might be possible to do using OR composite. Am I correct?
Another question is if I can create or alter rule sets programmatically?
Is that any way to do it using configuration files only? How about dependency injection?
I wonder also if i can create validator wich will allow me to reference rule set, so i can cain rule sets?
There probably more questions to ask, I just cannot formulate it now.
I will appreciate if somebody can share his success story of doing similar things!