diff --git a/src/Squidex.Write/Schemas/Commands/AddField.cs b/src/Squidex.Write/Schemas/Commands/AddField.cs index b487a89a4..2741f2b90 100644 --- a/src/Squidex.Write/Schemas/Commands/AddField.cs +++ b/src/Squidex.Write/Schemas/Commands/AddField.cs @@ -6,14 +6,23 @@ // All rights reserved. // ========================================================================== +using System; using System.Collections.Generic; using Squidex.Core.Schemas; using Squidex.Infrastructure; +using PartitioningOption = Squidex.Core.Partitioning; + namespace Squidex.Write.Schemas.Commands { public class AddField : FieldCommand, IValidatable { + private static readonly HashSet AllowedPartitions = new HashSet(StringComparer.OrdinalIgnoreCase) + { + PartitioningOption.Language.Key, + PartitioningOption.Invariant.Key + }; + public string Name { get; set; } public string Partitioning { get; set; } @@ -22,9 +31,9 @@ namespace Squidex.Write.Schemas.Commands public void Validate(IList errors) { - if (Partitioning != null && Partitioning != "language") + if (Partitioning != null && !AllowedPartitions.Contains(Partitioning)) { - errors.Add(new ValidationError("Partitioning must be invariant or language.", nameof(Partitioning))); + errors.Add(new ValidationError($"Partitioning must be one of {string.Join(", ", AllowedPartitions)}.", nameof(Partitioning))); } if (!Name.IsPropertyName())