// ========================================================================== // StringFieldPropertiesDto.cs // Squidex Headless CMS // ========================================================================== // Copyright (c) Squidex Group // All rights reserved. // ========================================================================== using System.Collections.Immutable; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using NJsonSchema.Annotations; using Squidex.Core.Schemas; using Squidex.Infrastructure.Reflection; namespace Squidex.Controllers.Api.Schemas.Models { [JsonSchema("string")] public sealed class StringFieldPropertiesDto : FieldPropertiesDto { /// /// The default value for the field value. /// public string DefaultValue { get; set; } /// /// The pattern to enforce a specific format for the field value. /// public string Pattern { get; set; } /// /// The validation message for the pattern. /// public string PatternMessage { get; set; } /// /// The minimum allowed length for the field value. /// public int? MinLength { get; set; } /// /// The maximum allowed length for the field value. /// public int? MaxLength { get; set; } /// /// The allowed values for the field value. /// public string[] AllowedValues { get; set; } /// /// The editor that is used to manage this field. /// [JsonConverter(typeof(StringEnumConverter))] public StringFieldEditor Editor { get; set; } public override FieldProperties ToProperties() { var result = SimpleMapper.Map(this, new StringFieldProperties()); if (AllowedValues != null) { result.AllowedValues = ImmutableList.Create(AllowedValues); } return result; } } }