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

namespace TakeoutSaaS.Application.App.Stores.Validators;

/// <summary>
/// 更新门店员工命令验证器。
/// </summary>
public sealed class UpdateStoreStaffCommandValidator : AbstractValidator<UpdateStoreStaffCommand>
{
    /// <summary>
    /// 初始化验证规则。
    /// </summary>
    public UpdateStoreStaffCommandValidator()
    {
        RuleFor(x => x.StaffId).GreaterThan(0);
        RuleFor(x => x.StoreId).GreaterThan(0);
        RuleFor(x => x.Name).NotEmpty().MaximumLength(64);
        RuleFor(x => x.Phone).NotEmpty().MaximumLength(32);
        RuleFor(x => x.Email).EmailAddress().When(x => !string.IsNullOrWhiteSpace(x.Email));
    }
}
