views:

34

answers:

1

I was looking at this article on custom validators in aps.net mvc 2 and I was wondering how I might go about creating a more complex validation which worked on multiple fields at once. Say something like

 if(fieldA > 7 and fieldB < 15)

The attribute method of creating validators doesn't seem like it would work for that.

+1  A: 

Hi, I have started using Fleunt validation and is allows you to achieve quite complex validation with ease. While it takes some getting used to, I have found it very flexible. For example, here we make sure the length of a user password is between 7 and 15!

    public UserValidator() {
  RuleFor(user=> user.Password)
   .Length(7, 15)
   .WithMessage("Password to short/long");
 }
Dai Bok