diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Validation/Constraint/TestFieldConstraint.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Validation/Constraint/TestFieldConstraint.php index fb258a6..14d172c 100644 --- a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Validation/Constraint/TestFieldConstraint.php +++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Validation/Constraint/TestFieldConstraint.php @@ -7,13 +7,13 @@ namespace Drupal\field_test\Plugin\Validation\Constraint; -use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Constraints\NotEqualTo; use Drupal\Component\Annotation\Plugin; use Drupal\Core\Annotation\Translation; /** - * Checks if a value is a valid. + * Checks if a value is not equal. * * @Plugin( * id = "TestField", @@ -21,41 +21,20 @@ * type = { "integer" } * ) */ -class TestFieldConstraint extends Constraint { - - /** - * The default violation message. - * - * @var string - */ - public $message = '%name does not accept the value @compare.'; - - /** - * The compare value. - * - * @var int - */ - public $compare; - - /** - * The compare name. - * - * @var string - */ - public $name; +class TestFieldConstraint extends NotEqualTo { /** * {@inheritdoc} */ - public function getDefaultOption() { - return 'compare'; + public function getRequiredOptions() { + return array('value'); } /** * {@inheritdoc} */ - public function getRequiredOptions() { - return array('compare', 'name'); + public function validatedBy() { + return '\Symfony\Component\Validator\Constraints\NotEqualToValidator'; } } diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Validation/Constraint/TestFieldConstraintValidator.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Validation/Constraint/TestFieldConstraintValidator.php deleted file mode 100644 index 25e85de..0000000 --- a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Validation/Constraint/TestFieldConstraintValidator.php +++ /dev/null @@ -1,28 +0,0 @@ -compare) { - $this->context->addViolation($constraint->message, array('%name' => $constraint->name, '@compare' => $constraint->compare)); - } - } - -} diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/field/field_type/TestItem.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/field/field_type/TestItem.php index 316eadd..cc4bd52 100644 --- a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/field/field_type/TestItem.php +++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/field/field_type/TestItem.php @@ -133,8 +133,8 @@ public function getConstraints() { $constraints[] = $constraint_manager->create('ComplexData', array( 'value' => array( 'TestField' => array( - 'compare' => -1, - 'name' => $this->getFieldDefinition()->getFieldLabel(), + 'value' => -1, + 'message' => t('%name does not accept the value @value.', array('%name' => $this->getFieldDefinition()->getFieldLabel(), '@value' => -1)), ) ), ));