public override bool IsValid(object value) { if (value == null || string.IsNullOrEmpty(value.ToString())) { return(true); } bool valido = BrazilianDocumentsValidations.ValidateCpf(value.ToString()); return(valido); }
public ClienteValidator() { RuleFor(b => b.Cpf) .NotNullWithMessage() .Custom((cpf, context) => { if (!BrazilianDocumentsValidations.ValidateCpf(cpf)) { context.AddFailure("CPF inválido"); } }); }
public BeneficiarioValidator() { RuleFor(b => b.Nome) .NotNullWithMessage() .MinimumLength(3) .MaximumLength(30); RuleFor(b => b.Cpf) .NotNullWithMessage() .Custom((cpf, context) => { if (!BrazilianDocumentsValidations.ValidateCpf(cpf)) { context.AddFailure("CPF inválido"); } }); }