From 9dc4c8e326872d169cbc00e4b195feefba46edf5 Mon Sep 17 00:00:00 2001 From: kolan72 Date: Mon, 5 May 2025 18:19:28 +0300 Subject: [PATCH 1/4] Add 'Nuances Of Using The Library' README Chapter. --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index ba94950..51dc7a1 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 initially provided in `AddFunc`/`AddProperty`/`AddField`. +For example, in this case `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 ObjToValidateOptions() { PercentValue1 = 200}); +``` + ## ❌ Drawbacks - Non-canonical way of using of FluentValidation. From 6e8ec66859a24e1cc91e6d34cb8fbdea9c0bce04 Mon Sep 17 00:00:00 2001 From: kolan72 Date: Tue, 6 May 2025 14:41:57 +0300 Subject: [PATCH 2/4] Edit ' Nuances Of Using The Library' README Chapter. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 51dc7a1..eabb5a3 100644 --- a/README.md +++ b/README.md @@ -132,14 +132,14 @@ 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 initially provided in `AddFunc`/`AddProperty`/`AddField`. -For example, in this case `result.Errors[0].PropertyName` will equal "percentSum" (the property name overridden in the validation rule): +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() +var result = new ExpressValidatorBuilder() .AddFunc(o => o.PercentValue1 + o.PercentValue2, "sum") .WithValidation((o) => o.InclusiveBetween(0, 100) .OverridePropertyName("percentSum")) - .BuildAndValidate(new ObjToValidateOptions() { PercentValue1 = 200}); + .BuildAndValidate(new ObjToValidate() { PercentValue1 = 200}); ``` ## ❌ Drawbacks From 9d798db594d45c909ad78307f58b2e29d8fec342 Mon Sep 17 00:00:00 2001 From: kolan72 Date: Tue, 6 May 2025 15:19:01 +0300 Subject: [PATCH 3/4] Edit ' Nuances Of Using The Library' README Chapter -args clarification. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eabb5a3..740693e 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ 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 initially provided in `AddFunc`/`AddProperty`/`AddField`. +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" From 19bfb2ab4f17f304e2d743f96f02891ba6eebd23 Mon Sep 17 00:00:00 2001 From: kolan72 Date: Mon, 19 May 2025 17:36:47 +0300 Subject: [PATCH 4/4] Update NuGet.md. --- src/ExpressValidator/docs/NuGet.md | 1 + 1 file changed, 1 insertion(+) 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: