Placing rules in one config file per class

Topics: Validation Application Block
May 18, 2007 at 4:07 PM
Hi is there a way to place my validation rules in separate files so that I can have (for example) IPerson.Config, IPhoneNumber.Config, and IAddress.Config?

May 18, 2007 at 4:26 PM
Yes. Just specify the name of the file where the validation rules are located:

Customer customer = new Customer();
customer.Name = "ThisIsTooLongForACustomerName";
Validator<Customer> customerValidator =
    ValidationFactory.CreateValidator<Customer>(new FileConfigurationSource("Customer.config"));
ValidationResults results = customerValidator.Validate(customer);




David Hayden
Microsoft MVP C#