Does xVal need data annotations on the model?

Oct 4, 2010 at 9:11 AM
Edited Oct 4, 2010 at 9:11 AM

Does xVal only work with data annotations? Is is possible to keep my domain entities clean of validation annotations? I see the following:

"you can also write your own IRulesProvider to attach rules programmatically or using any other .NET validation framework.: but have not seen any implemtation of this.

I have been working with FluentValidation which allows you to abstract the validation like:

public class Person

{
     public string Name {get;set;}
}

public class PersonValidator: AbstractValidator<Person>
    {
        public PersonValidator()
        {
            RuleFor(x => x.Name).NotEmpty().Length(2);
        }
}

ValidationResult result = Person.Validate(new PersonValidator());

I want to try and keep my domain model free from a lot of annotations. Is something similar possible with xVal?

Cheers