using FluentValidation;
using TakeoutSaaS.Application.Dictionary.Contracts;

namespace TakeoutSaaS.Application.Dictionary.Validators;

/// <summary>
/// 创建字典分组请求验证器。
/// </summary>
public sealed class CreateDictionaryGroupValidator : AbstractValidator<CreateDictionaryGroupRequest>
{
    public CreateDictionaryGroupValidator()
    {
        RuleFor(x => x.Code)
            .NotEmpty()
            .Length(2, 64)
            .Matches("^[a-zA-Z0-9_]+$");

        RuleFor(x => x.Name)
            .NotEmpty()
            .MaximumLength(128);

        RuleFor(x => x.Scope)
            .IsInEnum();
    }
}
