You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i would like that my validation has ErrorCode and errorMessage
I'm using CustomResultFactory, find below my configuration, but i'm not able to find the object that contains errors with code and messagge (the same object that i find when i use manual validation)
FluentValidation.Results.ValidationFailure
public class CustomResultFactory : IFluentValidationAutoValidationResultFactory
{
public IActionResult CreateActionResult(ActionExecutingContext context, ValidationProblemDetails? validationProblemDetails)
{
return new BadRequestObjectResult(new { Title = "Validation errors", ValidationErrors = validationProblemDetails?.Errors });
}
}
services.AddFluentValidationAutoValidation(configuration =>
{
// Disable the built-in .NET model (data annotations) validation.
configuration.DisableBuiltInModelValidation = true;
// Only validate controllers decorated with the `FluentValidationAutoValidation` attribute.
configuration.ValidationStrategy = ValidationStrategy.All;
// Enable validation for parameters bound from the `BindingSource.Body` binding source.
configuration.EnableBodyBindingSourceAutomaticValidation = true;
// Enable validation for parameters bound from the `BindingSource.Form` binding source.
configuration.EnableFormBindingSourceAutomaticValidation = true;
// Enable validation for parameters bound from the `BindingSource.Query` binding source.
configuration.EnableQueryBindingSourceAutomaticValidation = true;
// Replace the default result factory with a custom implementation.
configuration.OverrideDefaultResultFactoryWith<CustomResultFactory>();
});
The text was updated successfully, but these errors were encountered:
Hi, currently the complete validation result is not passed to the custom factory unfortunately. I will look into a way to expose it without introducing breaking changes. If not possible this feature is going to have to wait for v2.
mvdgun
changed the title
NET 6 - FluentValidation AutoValidation -
Improve/extend context in the IFluentValidationAutoValidationResultFactory
Oct 19, 2023
hi,
i'm using rules with ErrorCode and ErrorMessage, example:
i would like that my validation has ErrorCode and errorMessage
I'm using CustomResultFactory, find below my configuration, but i'm not able to find the object that contains errors with code and messagge (the same object that i find when i use manual validation)
The text was updated successfully, but these errors were encountered: