44 lines
1.7 KiB
C#
44 lines
1.7 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("Employee ID is required for update");
|
|
|
|
RuleFor(x => x.Code)
|
|
.NotEmpty().WithMessage("Employee Code is required")
|
|
.MaximumLength(GlobalConsts.StringLengthShort).WithMessage($"Code cannot exceed {GlobalConsts.StringLengthShort} characters");
|
|
|
|
RuleFor(x => x.FirstName)
|
|
.NotEmpty().WithMessage("First Name is required")
|
|
.MaximumLength(GlobalConsts.StringLengthShort).WithMessage($"First Name cannot exceed {GlobalConsts.StringLengthShort} characters");
|
|
|
|
RuleFor(x => x.LastName)
|
|
.NotEmpty().WithMessage("Last Name is required")
|
|
.MaximumLength(GlobalConsts.StringLengthShort).WithMessage($"Last Name cannot exceed {GlobalConsts.StringLengthShort} characters");
|
|
|
|
RuleFor(x => x.Email)
|
|
.NotEmpty().WithMessage("Email is required")
|
|
.EmailAddress().WithMessage("Invalid email format");
|
|
|
|
RuleFor(x => x.BranchId)
|
|
.NotEmpty().WithMessage("Please select a Branch");
|
|
|
|
RuleFor(x => x.DepartmentId)
|
|
.NotEmpty().WithMessage("Please select a Department");
|
|
|
|
RuleFor(x => x.DesignationId)
|
|
.NotEmpty().WithMessage("Please select a Designation");
|
|
|
|
RuleFor(x => x.GradeId)
|
|
.NotEmpty().WithMessage("Please select a Salary Grade");
|
|
|
|
RuleFor(x => x.BasicSalary)
|
|
.GreaterThan(0).WithMessage("Basic Salary must be greater than 0");
|
|
}
|
|
} |