// ========================================================================== // 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 message, Action> action) { var errors = new List(); action(errors.Add); if (errors.Any()) { throw new ValidationException(message(), errors); } } public static async Task It(Func message, Func, Task> action) { var errors = new List(); await action(errors.Add); if (errors.Any()) { throw new ValidationException(message(), errors); } } } }