Headless CMS and Content Managment Hub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

42 lines
1.2 KiB

// ==========================================================================
// TypeNameRegistry.cs
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex Group
// All rights reserved.
// ==========================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Squidex.Infrastructure
{
public static class Validate
{
public static void It(Func<string> message, Action<Action<ValidationError>> action)
{
var errors = new List<ValidationError>();
action(errors.Add);
if (errors.Any())
{
throw new ValidationException(message(), errors);
}
}
public static async Task It(Func<string> message, Func<Action<ValidationError>, Task> action)
{
var errors = new List<ValidationError>();
await action(errors.Add);
if (errors.Any())
{
throw new ValidationException(message(), errors);
}
}
}
}