31 lines
1.0 KiB
C#
31 lines
1.0 KiB
C#
using FluentValidation;
|
|
using Indotalent.Shared.Consts;
|
|
|
|
namespace Indotalent.Features.Payroll.Grade.Cqrs;
|
|
|
|
public class UpdateGradeValidator : AbstractValidator<UpdateGradeRequest>
|
|
{
|
|
public UpdateGradeValidator()
|
|
{
|
|
RuleFor(x => x.Id)
|
|
.NotEmpty().WithMessage("ID is required for update");
|
|
|
|
RuleFor(x => x.Code)
|
|
.NotEmpty().WithMessage("Grade Code is required")
|
|
.MaximumLength(GlobalConsts.StringLengthShort);
|
|
|
|
RuleFor(x => x.Name)
|
|
.NotEmpty().WithMessage("Grade Name is required")
|
|
.MaximumLength(GlobalConsts.StringLengthShort);
|
|
|
|
RuleFor(x => x.SalaryFrom)
|
|
.GreaterThanOrEqualTo(0).WithMessage("Salary From must be 0 or greater");
|
|
|
|
RuleFor(x => x.SalaryTo)
|
|
.GreaterThanOrEqualTo(x => x.SalaryFrom).WithMessage("Salary To must be greater than or equal to Salary From");
|
|
|
|
RuleFor(x => x.Status)
|
|
.NotEmpty().WithMessage("Status is required")
|
|
.MaximumLength(GlobalConsts.StringLengthShort);
|
|
}
|
|
} |