using FluentValidation;
using XF.Domain.Extensions;

namespace Hotline.Validators;

public static class ValidatorExtensions
{
    /// <summary>
    /// Guid结构的字符串
    /// </summary>
    public static IRuleBuilderOptions<TDto, string> IsGuidStructureString<TDto>(this IRuleBuilderInitial<TDto, string> initial) =>
        initial.Cascade(CascadeMode.Stop).NotEmpty().Must(d => d.IsGuidString());
    
    public static IRuleBuilderOptions<TDto, string> MaxLengthWithChineseChar<TDto>(this IRuleBuilderInitial<TDto, string> initial, int maxLength) =>
        initial.Cascade(CascadeMode.Stop).Must(d => d.GetChineseCharLength() < maxLength);
}