123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using Exam.Infrastructure.Extensions;
- using Exam.Infrastructure.Validation.Validation;
- using FluentValidation;
- using Hotline.Exams.ExamManages;
- using Hotline.Exams.Validate;
- using Hotline.Repository.SqlSugar.Validate;
- namespace Hotline.Repository.SqlSugar.Exam.Validators.ExamManages
- {
- public class ExamQuestionAnswerValidator : BaseValidator<ExamQuestionAnswerBak>
- {
- public ExamQuestionAnswerValidator()
- {
- RuleSet(ValidatorTypeConstants.Create, () =>
- {
- BaseValidateRule();
- ValidateRuleWithAdd();
- });
- RuleSet(ValidatorTypeConstants.Modify, () =>
- {
- BaseValidateRule();
- ValidateRuleWithModify();
- });
- }
- protected override void BaseValidateRule()
- {
- base.BaseValidateRule();
- }
- protected override void ValidateRuleWithAdd()
- {
- base.ValidateRuleWithAdd();
- RuleFor(m => m.CreationTime).NotEmpty().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamQuestionBak.CreationTime))));
- }
- protected override void ValidateRuleWithModify()
- {
- base.ValidateRuleWithModify();
- RuleFor(m => m.LastModificationTime).NotEmpty().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamQuestionBak.LastModificationTime))));
- }
- }
- }
|