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

Created Issue: OverridePropertyName is ignored with SetCollectionValidator [7129]

$
0
0
ValidationResult.PropertyName is generally affected by .OverridePropertyName, except where there is a collection validator. In these cases, ValidationResult.PropertyName still matches the (indexed) collection property name.

For example:

```
RuleFor(ow => ow.FineComponentCollection)
.Must((ow, coll) => coll.Any(fc => fc.Amount > 0))
.When(ow => ow.FineComponentCollection.Count > 0)
.OverridePropertyName("Test") // this works
.WithMessage("At least one non-zero monetary amount must be specified.");

RuleFor(ow => ow.FineComponentCollection)
.SetCollectionValidator(OutcomeFineComponentValidator.GetValidator(isNewEntity))
.OverridePropertyName("Test"); // this doesn't work
```
In the latter case, my ValidationResult.PropertyName still ends up as something like "FineComponentCollection[2].Amount" instead of "Test[2].Amount"

Viewing all articles
Browse latest Browse all 1917

Trending Articles



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