views:

164

answers:

1

Hi,

I'm trying to use the Spring.net framework for the first time. I would like to use its validation capabilities. I'm currently trying to validate business objects, so I have defined several validators (in the App config file). I retrieve these validators through the IOC (ContextRegistry.GetContext().GetObject(validator name)). I would like to know if it's possible to associate a validator to an object as it's the case in the Enterprise library.

Thanks for your time

+1  A: 
IValidator validator = ContextRegistry.GetContext().GetObject("validator name") as IValidator;
IValidationErrors validationErrors = new ValidationErrors();
validator.Validate(myObjectToValidate, validationErrors);

you can also use the Validation Aspect (using attributes)

brunob