diff --git a/README.md b/README.md index ba94950..740693e 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,19 @@ if(!result2.IsValid) } ``` +## 🧩 Nuances Of Using The Library + +For `ExpressValidatorBuilder` methods (`AddFunc`, `AddProperty`, and `AddField`), the overridden property name (set via `FluentValidation`'s `OverridePropertyName` method in `With(Async)Validation`) takes precedence over the property name passed as a string or via `Expression` in `AddFunc`/`AddProperty`/`AddField`. +For example, for the `ObjToValidate` object from the 'Quick Start' chapter, `result.Errors[0].PropertyName` will equal "percentSum" (the property name overridden in the validation rule): +```csharp +// result0.Errors[0].PropertyName == "percentSum" +var result = new ExpressValidatorBuilder() + .AddFunc(o => o.PercentValue1 + o.PercentValue2, "sum") + .WithValidation((o) => o.InclusiveBetween(0, 100) + .OverridePropertyName("percentSum")) + .BuildAndValidate(new ObjToValidate() { PercentValue1 = 200}); +``` + ## ❌ Drawbacks - Non-canonical way of using of FluentValidation. diff --git a/src/ExpressValidator/docs/NuGet.md b/src/ExpressValidator/docs/NuGet.md index 7bbdb60..7868253 100644 --- a/src/ExpressValidator/docs/NuGet.md +++ b/src/ExpressValidator/docs/NuGet.md @@ -50,6 +50,7 @@ if(!result.IsValid) //As usual with validation result... } ``` +## Modifying FluentValidation Validator Parameters Using Options To dynamically change the parameters of the `FluentValidation` validators: