Fluent validations doesnt return errro dto

Hi,
i have connected my fluentvalidation and have added validations.
The problem is that sometimes the error dto containing the error messages are not returned but instead the empty response dto.
Am I missing something?

I can see it stops and the error is complete
I have in my AppHost this confingration

Plugins.Add(new ValidationFeature { ErrorResponseFilter = ValidationErrorFilter });
  // Return your own validation result format here
    public static object ValidationErrorFilter(ValidationResult validationResult, object errorDto)
    {
        // Loop through the validationResult create your own custom error response object.
        // return your response object
        
        //foreach (var item in validationResult.Errors)
        //{
            
        //} 
        return errorDto;
    }

But instead it returns an empty DTO with the correct HTTPStatus Code 400 Predicate

  {
  "CategoryId": 0,
  "Active": false,
  "IsFavorite": false
}

Thx!

Does your Response DTO have the ResponseStatus property?

Hi,

yes it does,

        public ResponseStatus ResponseStatus { get; set; }

in the NewsItemQueryResponse class

And my fluent validator looks like this

public class NewsItemQueryValidator : BaseValidator<NewsItemQuery>
{
    public NewsItemQueryValidator()
    {
  
        RuleFor(r => r.Active)
            .NotEmpty().When(m => !IsAdmin.Value).WithMessage("You are only allowed to show active news when not admin");
    }
}

First debug to makes sure that the validator is definitely getting called and the Exception is not for some other reason.

If the validation exception is definitely getting called, put together a stand-alone repro and we’ll look into it.