I need to have your views on the following problem.
I have an object say "TestObj". It has the following attribute String "Attribute_A","Attribute_B". For one of my current needs i have stored these Class.Attribute in DB. e.g. TestObj.Attribute_A and TestObj.Attribute_B. In my Server side code i am fetching these values from the DB. Now i have to do some validation on these attributes which i retrieved from DB thinking as if they were the actual objects attribute. e.g. TestObj.Attribute_A > "500" TestObj.Attribute_B == "testString".
These validations have to be done on Server side and can be changed dynamically and hence are stored in DB.
Please let me know if anyone of you have done or read about such a problem earlier.Also i am open to your suggestion.
the validaiton rules are stored in DB ? and they tell you what rule to apply to what field ?
so ni your db you have something like
ID|FIELDNAME|OPERATOR|LEFTHANDSIDE 01| age | > | 18 02| color | == | "red"
and then you need to apply these rules to different objects ?
ok, that is pretty ugly pseudo code. There are lots of things to think about.... Null Values, Number vs. Strings. Where to store error messages ?
posted 13 years ago
Thank you all..
I will look into the reflection tuts...
Also i forgot to tell you all that our validation checks are basically all the complex logic possible & we have defined them in a TREE structure.The DB is similar to what Pascal has provided.So is there any other way to pull up the validation rules & execute them knowing that they are in a TREE structure.Meaning that
Any better way to handle the tree structure of preparing the validation ? Thanks.
I'd take a different approach. If I could control the input in the first place, I'd have validations to ensure that the values that I'm going to store into the database is of the constraints I defined. Or I could put in constraints at the database level to ensure that if for some reasons my Java validations failed, at least the database would reject these inputs.