19 lines
522 B
C#
19 lines
522 B
C#
using System.ComponentModel.DataAnnotations;
|
|
using GerstITS.Validation;
|
|
|
|
namespace GerstITS.Examples.Api.Endpoints;
|
|
|
|
internal static partial class Endpoints
|
|
{
|
|
internal static class Validator
|
|
{
|
|
internal static void Validate<T>(IValidator validator, T model)
|
|
{
|
|
var result = validator.Validate(model);
|
|
|
|
if (!result.IsValid)
|
|
throw new ValidationException($"{typeof(T).Name} is invalid.{Environment.NewLine}Details: {result.ToErrorMessage()}");
|
|
}
|
|
}
|
|
}
|