using Exam.Infrastructure.Extensions;
using FluentValidation;
using Hotline.Exams.Questions;
using Hotline.Exams.Validate;
using Hotline.Share.Dtos.Questions;

namespace Hotline.Validators.Exams
{
    public class AddQuestionDtoValidator:AbstractValidator<AddQuestionDto>
    {
        public AddQuestionDtoValidator()
        {
            RuleFor(m => m.Title).NotEmpty().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamQuestion.Title))));
            RuleFor(m => m.DifficultyLevel).NotNull().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamQuestion.DifficultyLevel))));
            RuleFor(m => m.FormalEnable).NotNull().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamQuestion.FormalEnable))));
            RuleFor(m => m.SimulateEnable).NotNull().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamQuestion.SimulateEnable))));

            RuleForEach(m => m.QuestionSourcewareDtos).SetValidator(new AddQuestionSourcewareDtoValidator());

            RuleForEach(m => m.QuestionKnowladgeDtos).SetValidator(new AddQuestionKnowladgeDtoValidator());

            RuleForEach(m => m.QuestionTagDtos).SetValidator(new AddQuestionTagDtoValidator());

            RuleForEach(m => m.QuestionOptionsDtos).SetValidator(new AddQuestionOptionsDtoValidator());
        
        }
    }
}
