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

New Post: Add error to collection if items invalid

$
0
0
It would be useful to be able to add an error for a collection property if any of the items fail validation.

Fantasy code below:
RuleFor(x => x.Guests)
    .SetCollectionValidator(x => new GuestValidator(dataSource, x.Guests))
    .AllItemsValid()
    .WithMessage("Please select a pickup point for each guest");
If the first guest element were invalid, the validation result would include errors on the Guests property and also on Guests[0].

Has anybody solved this issue with a simple extension? Is this worth considering as a core library feature?

Viewing all articles
Browse latest Browse all 1917

Trending Articles



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