How to validate method parameters using Policy injection validation call handler and Validation application block

May 1, 2012 at 5:43 AM

Hi,

I have a Class 'Admin' which contain a method "AddAlbum(Album album, string userName, int quantity)"

album : is an object of type Album [ with two properties : string Name, & decimal Cost]

Now I can easily set the validation call handler to a 'Validation Rule Set' defined in 'Validation application block' in WEB.CONFIG using enterprise library configuration tool.

My problem is : HOW to validate method parameters, i.e. :

I want to apply following validations on method parameters:

1. album => Not null; album.Name => Not null, string legth ( 5 to 10 characters long); album.Cost => range validator ( 15<Cost < 100)

2. userName => Not null, string Length validator

3. quantity => not null, range validator

 

Please assist me. I dont want code example BUT I want how to set configuration settings using enterprise library configuration tool OR directly in web / app .config file.

 

Thanks.