Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<ObjToValidate>()
.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.
Expand Down
1 change: 1 addition & 0 deletions src/ExpressValidator/docs/NuGet.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down