using FluentValidation;
using TakeoutSaaS.Application.App.Merchants.Commands;

namespace TakeoutSaaS.Application.App.Merchants.Validators;

/// <summary>
/// 创建商户命令验证器。
/// </summary>
public sealed class CreateMerchantCommandValidator : AbstractValidator<CreateMerchantCommand>
{
    /// <summary>
    /// 初始化验证规则。
    /// </summary>
    public CreateMerchantCommandValidator()
    {
        RuleFor(x => x.BrandName).NotEmpty().MaximumLength(128);
        RuleFor(x => x.BrandAlias).MaximumLength(64);
        RuleFor(x => x.LogoUrl).MaximumLength(256);
        RuleFor(x => x.Category).MaximumLength(64);
        RuleFor(x => x.ContactPhone).NotEmpty().MaximumLength(32);
        RuleFor(x => x.ContactEmail).EmailAddress().When(x => !string.IsNullOrWhiteSpace(x.ContactEmail));
        RuleFor(x => x.Province).MaximumLength(64);
        RuleFor(x => x.City).MaximumLength(64);
        RuleFor(x => x.District).MaximumLength(64);
        RuleFor(x => x.Address).MaximumLength(256);
    }
}
