basquiatraphaeu
basquiatraphaeu

Reputation: 667

How can I enable CascadeMode.Stop from FluentValidation throug IoC on ASP.NET Core 3?

I've seen it somewhere but couldn't find it anymore. Something like the following:


public class Startup {

public void ConfigureServices(IServiceCollection services)
{

services.AddControllers()
                .AddFluentValidation(s =>
                {   
                    s.ValidatorOptions.CascadeMode.Stop;                    
                    ...

Upvotes: 0

Views: 274

Answers (2)

basquiatraphaeu
basquiatraphaeu

Reputation: 667

Response from JeremySkinner the library maintainer:

Either:

using FluentValidation;
services.AddMvc().AddFluentValidation(fv => {
  fv.ValidatorOptions.CascadeMode = CascadeMode.Stop;
});

Or just:

ValidatorOptions.Global.CascadeMode = CascadeMode.Stop;

Both have the same result (they're the same configuration instance)

Upvotes: 0

Bryan Lewis
Bryan Lewis

Reputation: 5977

I believe it should be:

ValidatorOptions.CascadeMode = CascadeMode.Stop;

Upvotes: 1

Related Questions