class RestTestConstraintValidator in Drupal 10
Same name and namespace in other branches
- 8 core/modules/rest/tests/modules/rest_test/src/Plugin/Validation/Constraint/RestTestConstraintValidator.php \Drupal\rest_test\Plugin\Validation\Constraint\RestTestConstraintValidator
- 9 core/modules/rest/tests/modules/rest_test/src/Plugin/Validation/Constraint/RestTestConstraintValidator.php \Drupal\rest_test\Plugin\Validation\Constraint\RestTestConstraintValidator
Validator for \Drupal\rest_test\Plugin\Validation\Constraint\RestTestConstraint.
Hierarchy
- class \Drupal\rest_test\Plugin\Validation\Constraint\RestTestConstraintValidator extends \Symfony\Component\Validator\ConstraintValidator
Expanded class hierarchy of RestTestConstraintValidator
File
- core/
modules/ rest/ tests/ modules/ rest_test/ src/ Plugin/ Validation/ Constraint/ RestTestConstraintValidator.php, line 12
Namespace
Drupal\rest_test\Plugin\Validation\ConstraintView source
class RestTestConstraintValidator extends ConstraintValidator {
/**
* {@inheritdoc}
*/
public function validate($value, Constraint $constraint) {
if ($value instanceof FieldItemListInterface) {
$value = $value
->getValue();
if (!empty($value[0]['value']) && $value[0]['value'] === 'ALWAYS_FAIL') {
$this->context
->addViolation($constraint->message);
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RestTestConstraintValidator:: |
public | function |