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

namespace TakeoutSaaS.Application.Dictionary.Validators;

/// <summary>
/// 更新字典项请求验证器。
/// </summary>
public sealed class UpdateDictionaryItemValidator : AbstractValidator<UpdateDictionaryItemRequest>
{
    public UpdateDictionaryItemValidator()
    {
        RuleFor(x => x.Key)
            .NotEmpty()
            .MaximumLength(128);

        RuleFor(x => x.Value)
            .SetValidator(new I18nValueValidator());

        RuleFor(x => x.SortOrder)
            .GreaterThanOrEqualTo(0);
    }
}
