using FluentValidation;
using Meezi.Admin.API.Models;
using Meezi.Core.Utilities;

namespace Meezi.Admin.API.Validators;

public class SendOtpRequestValidator : AbstractValidator<SendOtpRequest>
{
    public SendOtpRequestValidator()
    {
        RuleFor(x => x.Phone).Must(PhoneNormalizer.IsValidIranMobile).WithMessage("Invalid phone number.");
    }
}

public class VerifyOtpRequestValidator : AbstractValidator<VerifyOtpRequest>
{
    public VerifyOtpRequestValidator()
    {
        RuleFor(x => x.Phone).Must(PhoneNormalizer.IsValidIranMobile);
        RuleFor(x => x.Code)
            .Must(OtpNormalizer.IsValidSixDigitCode)
            .WithMessage("OTP must be 6 digits.");
    }
}

public class RefreshTokenRequestValidator : AbstractValidator<RefreshTokenRequest>
{
    public RefreshTokenRequestValidator()
    {
        RuleFor(x => x.RefreshToken).NotEmpty();
    }
}
