15 lines
659 B
C#
15 lines
659 B
C#
using FluentValidation;
|
|
|
|
namespace Indotalent.Features.Leave.LeaveRequest.Cqrs;
|
|
|
|
public class CreateLeaveRequestValidator : AbstractValidator<CreateLeaveRequestRequest>
|
|
{
|
|
public CreateLeaveRequestValidator()
|
|
{
|
|
RuleFor(x => x.EmployeeId).NotEmpty().WithMessage("Employee is required");
|
|
RuleFor(x => x.LeaveCategoryId).NotEmpty().WithMessage("Leave Type is required");
|
|
RuleFor(x => x.StartDate).NotEmpty();
|
|
RuleFor(x => x.EndDate).NotEmpty().GreaterThanOrEqualTo(x => x.StartDate).WithMessage("End Date cannot be before Start Date");
|
|
RuleFor(x => x.Reason).NotEmpty().WithMessage("Reason is required");
|
|
}
|
|
} |