12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using Exam.ExamManages;
- using Exam.Infrastructure.Extensions;
- using Exam.Infrastructure.Validation.Validation;
- using FluentValidation;
- using Hotline.Repository.SqlSugar.Exam.Core.Constants;
- using Hotline.Repository.SqlSugar.Exam.Interfaces.ExamManages;
- using Hotline.Repository.SqlSugar.Interface;
- using Hotline.Repository.SqlSugar.Validate;
- namespace Hotline.Repository.SqlSugar.Exam.Validators.ExamManages
- {
- public class ExamAnswerValidator:BaseValidator<ExamAnswer>
- {
- private readonly IExamManageRepository _examManageRepository;
- public ExamAnswerValidator()
- {
- 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(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamAnswer.CreationTime))));
- }
- protected override void ValidateRuleWithModify()
- {
- base.ValidateRuleWithModify();
- RuleFor(m => m.LastModificationTime).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamAnswer.LastModificationTime))));
- }
- }
- }
|