0

I have two fields in my view model

 public decimal Rate { get; set; }
 public decimal GrossRate { get; set; }

Gross rate should be greater than or equal to Rate. Validate that whether gross rate is equal or greater than rate if gross rate enter is less it will display error message. Is there is something possible that I can validate from view model. I dont want to use if statement on postback.

Khizar Nayyar
  • 378
  • 1
  • 14
Farruk
  • 31
  • 1
  • 9
  • Check out FluentValidation.NET or the default MVC Data Annotations mechanism. – L-Four Feb 25 '16 at 11:26
  • Or use a [foolproof](http://foolproof.codeplex.com/) `[GreaterThanOrEqualTo]` or similar validation attribute –  Feb 25 '16 at 11:32
  • I use [ExpressiveAnnotations](https://github.com/jwaliszko/ExpressiveAnnotations) for stuff like this. You can then decorate your GrossRate property with a AssertThat attribute with the relevant condition. – mikeagg Feb 25 '16 at 11:33

0 Answers0