Browse Source

Added validation to `EntityTagSetDto` for Tags

pull/13718/head
malik masis 4 years ago
parent
commit
1751216a2e
  1. 21
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/EntityTagSetDto.cs

21
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/EntityTagSetDto.cs

@ -1,15 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
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; }
public List<string> Tags { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
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}",
new[] { nameof(Tags) }
);
}
}
}
}

Loading…
Cancel
Save