32 lines
956 B
C#
32 lines
956 B
C#
using FluentValidation;
|
|
using PARR.API.Contracts.V1.Requests;
|
|
using PARR.DAL.Services.Interfaces.Job;
|
|
|
|
namespace PARR.API.Validators
|
|
{
|
|
public class JobGroupValidator : AbstractValidator<JobGroupRequest>
|
|
{
|
|
public JobGroupValidator(IJobGroupTypeService jobGroupTypeService)
|
|
{
|
|
RuleFor(t => t.Name)
|
|
.NotNull().NotEmpty();
|
|
|
|
RuleFor(t => t.ShortDescription)
|
|
.NotNull().NotEmpty();
|
|
|
|
RuleFor(t => t.FullDescription)
|
|
.NotNull().NotEmpty();
|
|
|
|
RuleFor(t => t.Solution)
|
|
.NotNull().NotEmpty();
|
|
|
|
RuleFor(t => t.TemplateDuration)
|
|
.NotNull().NotEmpty();
|
|
|
|
RuleFor(t => t.GroupTypeId)
|
|
.MustAsync(async (entity, value, c) => await jobGroupTypeService.GetAsync(value) != null)
|
|
.WithMessage("Указан несуществующий Id типа");
|
|
}
|
|
}
|
|
}
|