Request: Add ObjectInstance to ValidationFailure
See original GitHub issueThe Microsoft Blazor front-end uses an ObjectInstance/PropertyName combination to identify errors, whereas FluentValidation uses a RootObject/PathToProperty.
Could we have some way of retrieving the actual object + property name (rather than path)?
For example. A ValidationFailure for Person.HomeAddress.City would give us
object Person.HomeAddress, string "City"
Take a look here for more information in a blog by Steve Sanderson - https://chrissainty.com/using-fluentvalidation-for-forms-validation-in-razor-components/
I’d be happy to submit a PR if you are open to the idea of this improvement and would like to discuss an approach you are happy with?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:18 (7 by maintainers)
Top Results From Across the Web
FluentValidation rule for null object
Add (new ValidationFailure("", "org is null")); return false; } return base. ... override void EnsureInstanceNotNull(object instance) { } }.
Read more >Validating object instances
The service has a single method: IEnumerable<ValidationError> Validate(object instance); . The service locates implementations of EPiServer.Validation.IValidate ...
Read more >Model validation in ASP.NET Core MVC and Razor Pages
To rerun validation, call ModelStateDictionary. ... Attach Validation Error Message to the Model on validation failure. if (Contact.
Read more >How To Implement Validation With MediatR And ... - YouTube
CQRS gives us a lot of flexibility to introduce additional behavior in the request pipeline. Join my weekly .
Read more >The Complete Guide To Validation In ASP.NET MVC 3 - Part 2
Finally, we compare the two property values and return a validation failure if they match. In some situations, you might be tempted to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
PropertyValidator
to pass the parent rule instance to theValidationFailure
Custom
validators where the user can create theValidationFailure
instance directly.I’m going to go ahead and close this issue as there hasn’t been any activity on it for nearly a year. If this is still something you’d like to have included in the project then please feel free to re-open the issue and submit a PR and I’d be happy to review it.