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

namespace Hotline.Validators.Exams
{
    public class UpdateQuestionDtoValidator:AbstractValidator<UpdateQuestionDto>
    {
        public UpdateQuestionDtoValidator()
        {
            //RuleFor(m => m.Id).NotEmpty().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamQuestion.Id))));
            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 UpdateQuestionSourcewareDtoValidator());

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

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

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