autobus-api_old/AutobusApi.Application/Common/Exceptions/ValidationException.cs
2023-11-15 19:00:34 +02:00

23 lines
608 B
C#

using FluentValidation.Results;
namespace AutobusApi.Application.Common.Exceptions;
public class ValidationException : Exception
{
public ValidationException()
: base("One or more validation failures have occurred.")
{
Errors = new Dictionary<string, string[]>();
}
public ValidationException(IEnumerable<ValidationFailure> failures)
: this()
{
Errors = failures
.GroupBy(f => f.PropertyName, f => f.ErrorMessage)
.ToDictionary(fg => fg.Key, fg => fg.ToArray());
}
public IDictionary<string, string[]> Errors { get; }
}