Validator from ValidatorData

Topics: Validation Application Block
Jun 7, 2007 at 10:08 PM
Hi,
I have the ValidatorData from configuration and I would like to convert this to a Validator. I can't do this similar to the AndCompositeValidator or the OrCompositeValidator, since they have access to the internal IValidatorDescriptor interface that they can use to call the CreateValidator() method. Does any one know how to do this?
I need the above functionality to be able to have a nested Validator with in my custom Validator and then use configuration for setting up the Validator.
Thanks,
Vasi
Jun 8, 2007 at 2:24 AM
Have you tried to create a untyped validator using the Application Block Software Factory that comes with Enterprise Library? It pretty much creates everything for you.

Off the top of my head it creates something similar to:

[ConfigurationElementType(typeof(CustomValidatorData))]
public class MyValidator : Validator
{
	public MyValidator(NameValueCollection values) : base(...)
	{
		// Get Values...
	}
	
	protected override void DoValidate(...)
	{
		// Validate...
	}	
}

You may also be able to find some examples as part of the EntLibContrib Project.

Regards,

Dave

___________________________________

David Hayden
Microsoft MVP C#
Jun 8, 2007 at 5:22 AM
This doesn't help in my situation since I need the Validator from ValidatorData for all the Validators in entlib. Also, at the time of conversion, I don't know what the exact types of the validators are (these validators could be strongly typed or untyped).
Vasi
Jun 9, 2007 at 4:26 PM
I would ask this in the EntLibContrib Project. It is all about creating new providers and application blocks.

You can also check out the screencast videos here.

Regards,

Dave

________________________________

David Hayden
Microsoft MVP C#