Files
2026-07-21 13:52:43 +07:00

34 lines
1.2 KiB
C#

using FluentValidation;
using Indotalent.Shared.Consts;
namespace Indotalent.Features.Organization.Employee.Cqrs;
public class CreateEmployeeValidator : AbstractValidator<CreateEmployeeRequest>
{
public CreateEmployeeValidator()
{
RuleFor(x => x.Name)
.NotEmpty().WithMessage("Employee Name is required")
.MaximumLength(GlobalConsts.StringLengthShort);
RuleFor(x => x.EmployeeNumber)
.NotEmpty().WithMessage("Employee Number is required")
.MaximumLength(GlobalConsts.StringLengthShort);
RuleFor(x => x.JobTitle)
.NotEmpty().WithMessage("Job Title is required")
.MaximumLength(GlobalConsts.StringLengthShort);
RuleFor(x => x.CommissionRate)
.GreaterThanOrEqualTo(0).WithMessage("Commission Rate cannot be negative");
RuleFor(x => x.EmailAddress)
.EmailAddress().When(x => !string.IsNullOrEmpty(x.EmailAddress));
RuleFor(x => x.EmployeeGroupId)
.NotEmpty().WithMessage("Employee Group is required");
RuleFor(x => x.EmployeeCategoryId)
.NotEmpty().WithMessage("Employee Category is required");
}
}