diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/EntityTagSetDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/EntityTagSetDto.cs index 245526cfc2a..11466463f83 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/EntityTagSetDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/EntityTagSetDto.cs @@ -1,15 +1,40 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.ComponentModel.DataAnnotations; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Localization; +using Volo.Abp.Validation.Localization; +using Volo.CmsKit.Localization; +using Volo.CmsKit.Tags; namespace Volo.CmsKit.Admin.Tags; [Serializable] -public class EntityTagSetDto +public class EntityTagSetDto : IValidatableObject { public string EntityId { get; set; } + public string EntityType { get; set; } + + [Required] public List Tags { get; set; } + + public IEnumerable Validate(ValidationContext validationContext) + { + var l = validationContext.GetRequiredService>(); + + foreach (var tag in Tags) + { + if (tag.Length > TagConsts.MaxNameLength) + { + yield return new ValidationResult( + l[ + "ThisFieldMustBeAStringWithAMaximumLengthOf{0}", + TagConsts.MaxNameLength + ], + new[] { nameof(Tags) } + ); + } + } + } }