RestTestConstraintValidator.php
Same filename in other branches
- 9 core/modules/rest/tests/modules/rest_test/src/Plugin/Validation/Constraint/RestTestConstraintValidator.php
- 10 core/modules/rest/tests/modules/rest_test/src/Plugin/Validation/Constraint/RestTestConstraintValidator.php
- 11.x core/modules/rest/tests/modules/rest_test/src/Plugin/Validation/Constraint/RestTestConstraintValidator.php
Namespace
Drupal\rest_test\Plugin\Validation\ConstraintFile
-
core/
modules/ rest/ tests/ modules/ rest_test/ src/ Plugin/ Validation/ Constraint/ RestTestConstraintValidator.php
View source
<?php
namespace Drupal\rest_test\Plugin\Validation\Constraint;
use Drupal\Core\Field\FieldItemListInterface;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
/**
* Validator for \Drupal\rest_test\Plugin\Validation\Constraint\RestTestConstraint.
*/
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);
}
}
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
RestTestConstraintValidator | Validator for \Drupal\rest_test\Plugin\Validation\Constraint\RestTestConstraint. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.