コード例 #1
0
 public CommandValidator(ICoursesValidator validator)
 {
     RuleFor(c => c.Title).NotEmpty().NotNull();
     RuleFor(c => c.Credits).InclusiveBetween(1, 5);
     RuleFor(c => c.Department.Name).NotEmpty().NotNull();
     RuleFor(c => c.Department.Name)
     .Must(name => validator.DepartmentExistsInDb(name))
     .WithMessage("The department must be present in the database.");
 }
コード例 #2
0
 public CommandValidator(ICoursesValidator validator)
 {
     RuleFor(c => c.Title).NotNull().Length(3, 50);
     RuleFor(c => c.Credits).NotNull().InclusiveBetween(0, 5);
     RuleFor(c => c.Department).NotNull();
 }