using Back.Data.Models;
using Back.Services;
using FluentValidation;
using Shared.DTOs;
using System;

namespace Back.Validations
{
    public class GetVerificationValidation : AbstractValidator<int>
    {
        public VerificationCode verificationCode { get; set; }
        public GetVerificationValidation(ServValidatinMsg _servValidatinMsg)
        {
            CascadeMode = CascadeMode.Stop;
            RuleFor(model => model)
            .Custom((model, context) => {
                verificationCode= _servValidatinMsg.GetVerificationCodeByID(model).Result;
                if (verificationCode==null)
                    context.AddFailure("کد یافت نشد");


            });
           
        }
    }
}
