Files
2026-07-21 14:22:06 +07:00

27 lines
843 B
C#

using FluentValidation;
using Indotalent.Shared.Consts;
namespace Indotalent.Features.Organization.Branch.Cqrs;
public class CreateBranchValidator : AbstractValidator<CreateBranchRequest>
{
public CreateBranchValidator()
{
RuleFor(x => x.Code)
.NotEmpty().WithMessage("Branch Code is required")
.MaximumLength(GlobalConsts.StringLengthShort);
RuleFor(x => x.Name)
.NotEmpty().WithMessage("Branch Name is required")
.MaximumLength(GlobalConsts.StringLengthShort);
RuleFor(x => x.City)
.NotEmpty().WithMessage("City is required");
RuleFor(x => x.StreetAddress)
.NotEmpty().WithMessage("Street Address is required");
RuleFor(x => x.Email)
.EmailAddress().When(x => !string.IsNullOrEmpty(x.Email));
}
}