58 lines
2.1 KiB
C#
58 lines
2.1 KiB
C#
using FluentValidation;
|
|
using Indotalent.Infrastructure.Database;
|
|
using Indotalent.Shared.Consts;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Indotalent.Features.Organization.Employee.Cqrs;
|
|
|
|
public class CreateEmployeeValidator : AbstractValidator<CreateEmployeeRequest>
|
|
{
|
|
public CreateEmployeeValidator()
|
|
{
|
|
|
|
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.IdentityNumber)
|
|
.NotEmpty().WithMessage("Identity Number is required");
|
|
|
|
RuleFor(x => x.JoinedDate)
|
|
.NotEmpty().WithMessage("Joined Date is required");
|
|
|
|
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.Gender)
|
|
.NotEmpty().WithMessage("Gender is required");
|
|
|
|
RuleFor(x => x.Phone)
|
|
.NotEmpty().WithMessage("Phone number is required");
|
|
|
|
RuleFor(x => x.BasicSalary)
|
|
.GreaterThan(0).WithMessage("Basic Salary must be greater than 0.");
|
|
|
|
|
|
}
|
|
} |