Skip to content

Commit

Permalink
Merge pull request #13718 from abpframework/Cms-kit-tag-issue-13417
Browse files Browse the repository at this point in the history
Cms-kit tag issues 13417
  • Loading branch information
enisn authored Aug 17, 2022
2 parents 6a4636c + dc534e5 commit 52682ae
Showing 1 changed file with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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<string> Tags { get; set; }

public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
var l = validationContext.GetRequiredService<IStringLocalizer<AbpValidationResource>>();

foreach (var tag in Tags)
{
if (tag.Length > TagConsts.MaxNameLength)
{
yield return new ValidationResult(
l[
"ThisFieldMustBeAStringWithAMaximumLengthOf{0}",
TagConsts.MaxNameLength
],
new[] { nameof(Tags) }
);
}
}
}
}

0 comments on commit 52682ae

Please sign in to comment.