Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Model Validation->all rules executed

$
0
0

Hi,

I am wondering if it is possible to make certain validation rules get executed in order but if one fails (error) then the next one not get executed.

For example:

public class MyViewModel
{
    [MaxLength(10)]
    [MinLength(15)]
    public string description { get; set; }
}

In this particular case, the validation attributes does not make sense, but for illustration purposes lets say the length the field "description" is 11, I get 2 errors: maxlength and minlength.  What I expect is that if maxlength fails the minlength does not get validated and I expect to get one single error.

Is this possible?

Thanks in advance and best regards,

Fabian


Viewing all articles
Browse latest Browse all 9386

Trending Articles



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