mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 06:03:12 +00:00
46 lines
1.5 KiB
C#
46 lines
1.5 KiB
C#
using FluentValidation;
|
|
using SeaHaven.Services.DTOs;
|
|
|
|
namespace SeaHaven.Services.Validation
|
|
{
|
|
public interface IWorkOrderBoardCreateValidation : IValidator<WorkOrderBoardCreateRequestDto>
|
|
{
|
|
}
|
|
|
|
public class WorkOrderBoardCreateValidation : AbstractValidator<WorkOrderBoardCreateRequestDto>, IWorkOrderBoardCreateValidation
|
|
{
|
|
public WorkOrderBoardCreateValidation()
|
|
{
|
|
RuleFor(x => x.WorkOrderType)
|
|
.IsInEnum().WithMessage("workOrderType is required and must be a valid value.");
|
|
|
|
RuleFor(x => x.SiteCode)
|
|
.NotEmpty().WithMessage("siteCode is required.")
|
|
.MaximumLength(32);
|
|
|
|
RuleFor(x => x.TargetWeek)
|
|
.NotNull().WithMessage("targetWeek is required when scheduleWeekOnly is true.")
|
|
.When(x => x.ScheduleWeekOnly == true);
|
|
|
|
RuleFor(x => x.Description)
|
|
.MaximumLength(2000)
|
|
.When(x => !string.IsNullOrEmpty(x.Description));
|
|
|
|
RuleFor(x => x.Trade)
|
|
.MaximumLength(128)
|
|
.When(x => !string.IsNullOrEmpty(x.Trade));
|
|
|
|
RuleFor(x => x.LocationId)
|
|
.GreaterThan(0)
|
|
.When(x => x.LocationId.HasValue);
|
|
|
|
RuleFor(x => x.VendorId)
|
|
.GreaterThan(0)
|
|
.When(x => x.VendorId.HasValue);
|
|
|
|
RuleFor(x => x.PocContactId)
|
|
.GreaterThan(0)
|
|
.When(x => x.PocContactId.HasValue);
|
|
}
|
|
}
|
|
}
|