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

Validate Model Properties and custom Validate rules at the same time.

$
0
0

I have a simple form with three fields: A name, a start date, and an end date.

The Name property is marked as [Required], and the Model implements IValidatableObject with the Validate method implemented to return a ValidationResult if start date is greater than end date.

All the Validation works, but not all at once. For example if I leave the Name field blank and enter a start date later than the end date the only error displayed is "Name is required". Only after I enter a name and resubmit do I see the "Start date must be before End date" message.

Is there a way to have all validation rules checked and sent-back at once?


Viewing all articles
Browse latest Browse all 9386

Trending Articles



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