|
|
|
@ -1,6 +1,9 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.ComponentModel.DataAnnotations; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Microsoft.Extensions.Localization; |
|
|
|
using Volo.CmsKit.Localization; |
|
|
|
using Volo.CmsKit.Tags; |
|
|
|
|
|
|
|
namespace Volo.CmsKit.Admin.Tags; |
|
|
|
@ -9,17 +12,27 @@ namespace Volo.CmsKit.Admin.Tags; |
|
|
|
public class EntityTagSetDto : IValidatableObject |
|
|
|
{ |
|
|
|
public string EntityId { get; set; } |
|
|
|
|
|
|
|
public string EntityType { get; set; } |
|
|
|
|
|
|
|
[Required] |
|
|
|
public List<string> Tags { get; set; } |
|
|
|
|
|
|
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) |
|
|
|
{ |
|
|
|
var l = validationContext.GetRequiredService<IStringLocalizer<CmsKitResource>>(); |
|
|
|
|
|
|
|
foreach (var tag in Tags) |
|
|
|
{ |
|
|
|
if (tag.Length > TagConsts.MaxNameLength) |
|
|
|
{ |
|
|
|
yield return new ValidationResult( |
|
|
|
$"{nameof(tag)} length must be equal to or lower than {TagConsts.MaxNameLength}", |
|
|
|
l[ |
|
|
|
"MaxTagLengthExceptionMessage", |
|
|
|
nameof(tag), |
|
|
|
TagConsts.MaxNameLength, |
|
|
|
typeof(EntityTagSetDto).FullName |
|
|
|
], |
|
|
|
new[] { nameof(Tags) } |
|
|
|
); |
|
|
|
} |
|
|
|
|