exception790
exception790

Reputation: 33

spring.net validation

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

Upvotes: 1

Views: 769

Answers (1)

brunob
brunob

Reputation: 71

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)

Upvotes: 1

Related Questions