Update to latest packages and show examples
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
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()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user