system-praktyk-api/src/InternshipSystem.Api/Queries/CourseForm.cs
2020-11-28 22:09:44 +01:00

23 lines
593 B
C#

using FluentValidation;
namespace InternshipSystem.Api.Queries
{
public class CourseForm
{
public long? Id { get; set; }
public string Name { get; set; }
public string NameEng { get; set; }
public class Validator : AbstractValidator<CourseForm>
{
public Validator()
{
RuleFor(c => c.Id).NotNull()
.When(c => string.IsNullOrWhiteSpace(c.Name));
RuleFor(c => c.Name).NotEmpty()
.When(c => !c.Id.HasValue);
}
}
}
}