/** * @inheritdoc */ protected function validate($value) { if (!Validator::cpf()->validate($value)) { throw new \InvalidArgumentException("O CPF informado é inválido"); } return true; }
/** * Define o CPF da pessoa física. * * @param string $cpf CPF da pessoa física * @return \Umbrella\YaBoleto\PessoaFisica */ public function setCpf($cpf) { if (!Validator::cpf()->validate($cpf)) { throw new \InvalidArgumentException("O CPF informado é inválido"); } $this->cpf = $cpf; return $this; }
public function validatePostVars($vars) { $validations = [v::stringType()->length(2)->validate($vars['nome']), v::stringType()->length(2)->validate($vars['sobrenome']), v::cpf()->validate($vars['cpf']), v::email()->validate($vars['email']), v::intVal()->validate($vars['clube']), v::intVal()->validate($vars['plano'])]; if ($vars['nascimento']) { $validations[] = v::date()->validate($vars['nascimento']); } if ($vars['titular']) { $validations[] = v::intVal()->validate($vars['titular']); } return $validations; }
public function setDocument($value) { $document = null; if (v::cnpj()->validate($value)) { $document = $this->setCNPJ($value); } if (v::cpf()->validate($value)) { $document = $this->setCPF($value); } if (is_null($document)) { throw new FieldRequiredException("Documento é uma informação obrigatória"); } }
/** * @return boolean * @param stdClass $user */ public function isValid($user) { $userValidator = v::attribute('ID', v::numeric())->attribute('USUARIO', v::string()->notEmpty()->noWhitespace())->attribute('NOME', v::string()->notEmpty())->attribute('EMAIL', v::email())->attribute('CPF', v::cpf())->attribute('STATUS', v::numeric())->attribute('UNIDADES', v::arr()); return $userValidator->validate($user); }