class NifValueValidator in Field NIF 8
Validates a NIF/CIF/NIE document number.
Hierarchy
- class \Drupal\field_nif\Plugin\Validation\Constraint\NifValueValidator extends \Symfony\Component\Validator\ConstraintValidator
Expanded class hierarchy of NifValueValidator
File
- src/
Plugin/ Validation/ Constraint/ NifValueValidator.php, line 12
Namespace
Drupal\field_nif\Plugin\Validation\ConstraintView source
class NifValueValidator extends ConstraintValidator {
/**
* {@inheritdoc}
*/
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())),
]);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
NifValueValidator:: |
public | function | Checks if the passed value is valid. |