Custom Validator with values from configuration file

Topics: Validation Application Block
Oct 15, 2007 at 2:34 PM
Edited Oct 15, 2007 at 2:35 PM
I have created a custom validator named MyCustomValidator. I've added the <MyCustomValidator()> attribute to the property I want to validate, and it works fine. The thing is, I would like MyCustomValidator to use values defined in my configuration file. I have used the Enterprise Library Configuration tool to add MyCustomValidator to the configuration file.

I tried to add a parameter to the MyCustomValidatorAttribute constructor but then I was required to pass a parameter to the <MyCustomValidator()> attribute. I want to use a value from the configuration file.

I also tried creating a third class named MyCustomValidatorData and passing its type to the ConfigurationElementType attribute of MyCustomValidator, but I can't get it to work.

Has anybody done this before or has any idea on how to do it?
Thanks in advance.