using FluentValidation; using SeaHaven.Services.DTOs; using Data.SeaHavenIndustries.Enums; namespace SeaHaven.Services.Validation { public interface ICreateFollowUpValidation : IValidator { } public class CreateFollowUpValidation : AbstractValidator, ICreateFollowUpValidation { public CreateFollowUpValidation() { RuleFor(x => x.Reason) .NotEmpty().WithMessage("Reason is required") .MaximumLength(500).WithMessage("Reason cannot exceed 500 characters"); RuleFor(x => x.Status) .NotEmpty().WithMessage("Status is required"); RuleFor(x => x.ScheduleDate) .GreaterThan(DateTime.Now.AddDays(-1)) .WithMessage("Schedule date cannot be in the past"); RuleFor(x => x.EmployeeId) .GreaterThan(0).WithMessage("Valid employee must be selected") .When(x => x.EmployeeId.HasValue); RuleFor(x => x.WorkOrderId) .GreaterThan(0).WithMessage("Valid work order must be selected") .When(x => x.WorkOrderId.HasValue); RuleFor(x => x.AccountId) .GreaterThan(0).WithMessage("Valid account must be selected") .When(x => x.AccountId.HasValue); RuleFor(x => x.LocationId) .GreaterThan(0).WithMessage("Valid location must be selected") .When(x => x.LocationId.HasValue); } } public interface IUpdateFollowUpValidation : IValidator { } public class UpdateFollowUpValidation : AbstractValidator, IUpdateFollowUpValidation { public UpdateFollowUpValidation() { RuleFor(x => x.Reason) .MaximumLength(500).WithMessage("Reason cannot exceed 500 characters") .When(x => !string.IsNullOrEmpty(x.Reason)); RuleFor(x => x.ScheduleDate) .GreaterThan(DateTime.Now.AddDays(-1)) .When(x => x.ScheduleDate.HasValue) .WithMessage("Schedule date cannot be in the past"); RuleFor(x => x.EmployeeId) .GreaterThan(0).WithMessage("Valid employee must be selected") .When(x => x.EmployeeId.HasValue); RuleFor(x => x.WorkOrderId) .GreaterThan(0).WithMessage("Valid work order must be selected") .When(x => x.WorkOrderId.HasValue); RuleFor(x => x.AccountId) .GreaterThan(0).WithMessage("Valid account must be selected") .When(x => x.AccountId.HasValue); RuleFor(x => x.LocationId) .GreaterThan(0).WithMessage("Valid location must be selected") .When(x => x.LocationId.HasValue); } } }