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

namespace Meezi.API.Validators;

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

public class VerifyOtpRequestValidator : AbstractValidator<VerifyOtpRequest>
{
    public VerifyOtpRequestValidator()
    {
        RuleFor(x => x.Phone)
            .NotEmpty()
            .Must(p => PhoneNormalizer.IsValidIranMobile(PhoneNormalizer.Normalize(p)))
            .WithMessage("Invalid Iranian mobile number.");

        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();
    }
}
