public function IsbnConstraintValidator::validate in ISBN Field 8
File
- src/
Plugin/ Validation/ Constraint/ IsbnConstraintValidator.php, line 10
Class
Namespace
Drupal\isbn\Plugin\Validation\ConstraintCode
public function validate($value, Constraint $constraint) {
if (gettype($value) == 'string') {
$isbn_tools = \Drupal::service("isbn.isbn_service");
if (!$isbn_tools
->isValidIsbn($value)) {
$this->context
->addViolation(t('"%isbn" isn\'t a valid ISBN number.', [
'%isbn' => $value,
]));
}
}
}