question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Request: Add ObjectInstance to ValidationFailure

See original GitHub issue

The 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:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:18 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
JeremySkinnercommented, Sep 30, 2019
  • Update PropertyValidator to pass the parent rule instance to the ValidationFailure
  • Need to decide how to handle Custom validators where the user can create the ValidationFailure instance directly.
  • Ensure there are tests in place to make sure serialization isn’t affected
0reactions
JeremySkinnercommented, Aug 4, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found