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

37 lines
1.3 KiB
C#

using FluentValidation;
using Indotalent.Shared.Consts;
namespace Indotalent.Features.Organization.Employee.Cqrs;
public class UpdateEmployeeValidator : AbstractValidator<UpdateEmployeeRequest>
{
public UpdateEmployeeValidator()
{
RuleFor(x => x.Id)
.NotEmpty().WithMessage("ID is required for update");
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");
}
}