예제 #1
0
        private static IActionResult ResultBadRequestFluentValidation(IDictionary <string, string[]> exceptions)
        {
            var ex = new FluentValidationExceptionResponseBody()
            {
                Status = StatusCodes.Status400BadRequest
            };

            foreach (var(key, value) in exceptions)
            {
                ex.Errors.Add(Utility.ToCamelCase(key), value);
            }

            return(new JsonResult(ex));
        }
        public static IActionResult Response(ActionContext context)
        {
            var problemDetails = new ValidationProblemDetails(context.ModelState);

            var exceptionBody = new FluentValidationExceptionResponseBody()
            {
                Status = StatusCodes.Status400BadRequest
            };

            foreach (var(key, value) in problemDetails.Errors)
            {
                exceptionBody.Errors.Add(Utility.ToCamelCase(key), value);
            }

            var result = new BadRequestObjectResult(exceptionBody);

            return(result);
        }