Quantcast
Channel: Fluent Validation for .NET
Viewing all articles
Browse latest Browse all 1917

New Post: Validate total across multiple properties

$
0
0
I have a group of "percentage" properties in my view model. As a simple example:
public class ViewModel
{
     public int Percent1 { get; set; }
     public int Percent2 { get; set; }
     public int Percent3 { get; set; }
     public int Percent4 { get; set; }
}
I need to write a validation rule that ensures the total of these four properties equals 100. From what I've read, fluent validation requires that a rule be applied to an individual property rather than across multiple properties.

Is there an elegant way to do this within the confines of the FluentValidation framework?

Viewing all articles
Browse latest Browse all 1917

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>