using FluentValidation;
using Indotalent.Shared.Consts;

namespace Indotalent.Features.Pipeline.SalesRepresentative.Cqrs;

public class CreateSalesRepresentativeValidator : AbstractValidator<CreateSalesRepresentativeRequest>
{
    public CreateSalesRepresentativeValidator()
    {
        RuleFor(x => x.Name)
            .NotEmpty().WithMessage("Representative Name is required")
            .MaximumLength(GlobalConsts.StringLengthShort);

        RuleFor(x => x.SalesTeamId)
            .NotEmpty().WithMessage("Sales Team is required");

        RuleFor(x => x.EmailAddress)
            .EmailAddress().When(x => !string.IsNullOrEmpty(x.EmailAddress));
    }
}