-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13718 from abpframework/Cms-kit-tag-issue-13417
Cms-kit tag issues 13417
- Loading branch information
Showing
1 changed file
with
29 additions
and
4 deletions.
There are no files selected for viewing
33 changes: 29 additions & 4 deletions
33
...kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/EntityTagSetDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) } | ||
); | ||
} | ||
} | ||
} | ||
} |