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.

Mulitple validation of a single property

See original GitHub issue

Hi,

I’m using FluentValidation in my WebAPI service and after upgrading the packages from 7.0.0-beta2 to 7.0.0, a following problem arised.

Take a look at a simplified scenario:


class A
{ }

class B
{
   public A A { get; set; }
}

class AValidator : AbstractValidator<A>
{ }

class BValidator : AbstractValidator<B>
{
   BValidator ()
   {
      this.RuleFor(o => o.A).SetValidator(new AValidator());
   }
}

Both validators are registered in the Unity container (instance of A can also be a controller method parameter):

container.RegisterType<IValidator<A>, AValidator>();
container.RegisterType<IValidator<B>, BValidator>();

Validating B results in executing the AValidator twice and giving duplicated validation results.

Any ideas? Thanks.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
JeremySkinnercommented, May 23, 2017

I’ve pushed 7.0.1 to nuget which contains a new property on the FluentValidationModelValidatorProvider called DisableDiscoveryOfPropertyValidators. If you set this to true then you’ll get the 6.4 behaviour back. Please give it a try.

0reactions
JeremySkinnercommented, May 24, 2017

Great, glad it’s working!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Validate multiple properties with one message
I'm trying to validate a class that has three required properties. If one or more of them is null it should trigger a...
Read more >
Introduction to Validate Multiple Data Model Properties ...
This articles describes the various techniques to apply the multiple model state validator inside the GridView using ASP.NET 4.5.
Read more >
Add multiple validations to a single property · Issue #3
Add support for multiple validations in the same property since it's supported in the ValidationContext side. ... Basically, if more than one ......
Read more >
Validate Property Values - MATLAB & Simulink
When inheriting validation for a property from multiple classes, only a single abstract property in one superclass can define the validation.
Read more >
validate multiple property in pegalist | Support Center
Hi, I use pega 7.1.7 and I want to validate multiple property at the same time in pagelist. Which one function of pega...
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