using FluentValidation; using Indotalent.Shared.Consts; namespace Indotalent.Features.Pipeline.Lead.Cqrs; public class UpdateLeadValidator : AbstractValidator { public UpdateLeadValidator() { RuleFor(x => x.Id).NotEmpty(); RuleFor(x => x.Title).NotEmpty().MaximumLength(GlobalConsts.StringLengthShort); RuleFor(x => x.CompanyName).NotEmpty().MaximumLength(GlobalConsts.StringLengthShort); RuleFor(x => x.CampaignId).NotEmpty(); RuleFor(x => x.SalesTeamId).NotEmpty(); } public Func>> ValidateValue() => async (model, propertyName) => { var result = await ValidateAsync(ValidationContext.CreateWithOptions((UpdateLeadRequest)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); }; }