public function NifValueValidator::validate in Field NIF 8
File
- src/
Plugin/ Validation/ Constraint/ NifValueValidator.php, line 17
Class
- NifValueValidator
- Validates a NIF/CIF/NIE document number.
Namespace
Drupal\field_nif\Plugin\Validation\ConstraintCode
public function validate($value, Constraint $constraint) {
$document_value = NifUtils::validateNifCifNie($value, $constraint
->getSupportedTypes());
if (!$document_value) {
$this->context
->addViolation($constraint
->getMessage(), [
'@value' => $value,
'@document_type' => empty($constraint
->getSupportedTypes()) ? 'NIF/CIF/NIE' : mb_strtoupper(implode('/', $constraint
->getSupportedTypes())),
]);
}
}