예제 #1
0
 public RankCreateValidator(IRankRepository rankRepository)
 {
     RuleFor(r => r.HigherRankId)
     .MustAsync(async(id, cancelation) =>
     {
         return(id != (await rankRepository.GetMaxIdAsync()) + 1);
     }).When(r => r.HigherRankId != null).WithMessage("{PropertyName} must be other rank.");
     RuleFor(r => r.Name)
     .NotEmpty().WithMessage("{PropertyName} is required.");
 }