Permalink
Browse files

[Validator] remove the API_VERSION

  • Loading branch information...
fabpot committed Sep 30, 2015
1 parent 2a6b629 commit 8fd32ba9fe51754c3b7d6b3693e39ed6256830c1
Showing with 20 additions and 1,012 deletions.
  1. +0 −6 src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php
  2. +0 −6 src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php
  3. +4 −12 src/Symfony/Component/Validator/Constraints/AllValidator.php
  4. +16 −40 src/Symfony/Component/Validator/Constraints/CollectionValidator.php
  5. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php
  6. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php
  7. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php
  8. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php
  9. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php
  10. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php
  11. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php
  12. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php
  13. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php
  14. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php
  15. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php
  16. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php
  17. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php
  18. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php
  19. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php
  20. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php
  21. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php
  22. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php
  23. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php
  24. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php
  25. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php
  26. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php
  27. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/IsFalseValidatorTest.php
  28. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/IsNullValidatorTest.php
  29. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/IsTrueValidatorTest.php
  30. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php
  31. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php
  32. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php
  33. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php
  34. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php
  35. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php
  36. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php
  37. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php
  38. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php
  39. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php
  40. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php
  41. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php
  42. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php
  43. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php
  44. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php
  45. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php
  46. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php
  47. +0 −5 src/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php
  48. +0 −658 src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php
  49. +0 −57 src/Symfony/Component/Validator/Tests/Validator/RecursiveValidator2Dot5ApiTest.php
  50. +0 −18 src/Symfony/Component/Validator/Validation.php
@@ -22,7 +22,6 @@
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator;
use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest;
use Symfony\Component\Validator\Validation;
use Doctrine\ORM\Tools\SchemaTool;
/**
@@ -47,11 +46,6 @@ class UniqueEntityValidatorTest extends AbstractConstraintValidatorTest
*/
protected $repository;
protected function getApiVersion()
{
return Validation::API_VERSION_2_5;
}
protected function setUp()
{
$this->em = DoctrineTestHelper::createTestEntityManager();
@@ -22,7 +22,6 @@
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Valid;
use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest;
use Symfony\Component\Validator\Validation;
/**
* @author Bernhard Schussek <bschussek@gmail.com>
@@ -56,11 +55,6 @@ protected function setUp()
parent::setUp();
}
protected function getApiVersion()
{
return Validation::API_VERSION_2_5;
}
protected function createValidator()
{
return new FormValidator($this->serverParams);
@@ -13,7 +13,6 @@
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
/**
@@ -40,17 +39,10 @@ public function validate($value, Constraint $constraint)
$context = $this->context;
if ($context instanceof ExecutionContextInterface) {
$validator = $context->getValidator()->inContext($context);
foreach ($value as $key => $element) {
$validator->atPath('['.$key.']')->validate($element, $constraint->constraints);
}
} else {
// 2.4 API
foreach ($value as $key => $element) {
$context->validateValue($element, $constraint->constraints, '['.$key.']');
}
$validator = $context->getValidator()->inContext($context);
foreach ($value as $key => $element) {
$validator->atPath('['.$key.']')->validate($element, $constraint->constraints);
}
}
}
@@ -13,7 +13,6 @@
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
/**
@@ -56,53 +55,30 @@ public function validate($value, Constraint $constraint)
if ($existsInArray || $existsInArrayAccess) {
if (count($fieldConstraint->constraints) > 0) {
if ($context instanceof ExecutionContextInterface) {
$context->getValidator()
->inContext($context)
->atPath('['.$field.']')
->validate($value[$field], $fieldConstraint->constraints);
} else {
// 2.4 API
$context->validateValue($value[$field], $fieldConstraint->constraints, '['.$field.']');
}
}
} elseif (!$fieldConstraint instanceof Optional && !$constraint->allowMissingFields) {
if ($context instanceof ExecutionContextInterface) {
$context->buildViolation($constraint->missingFieldsMessage)
->atPath('['.$field.']')
->setParameter('{{ field }}', $this->formatValue($field))
->setInvalidValue(null)
->setCode(Collection::MISSING_FIELD_ERROR)
->addViolation();
} else {
$this->buildViolationInContext($context, $constraint->missingFieldsMessage)
$context->getValidator()
->inContext($context)
->atPath('['.$field.']')
->setParameter('{{ field }}', $this->formatValue($field))
->setInvalidValue(null)
->setCode(Collection::MISSING_FIELD_ERROR)
->addViolation();
->validate($value[$field], $fieldConstraint->constraints);
}
} elseif (!$fieldConstraint instanceof Optional && !$constraint->allowMissingFields) {
$context->buildViolation($constraint->missingFieldsMessage)
->atPath('['.$field.']')
->setParameter('{{ field }}', $this->formatValue($field))
->setInvalidValue(null)
->setCode(Collection::MISSING_FIELD_ERROR)
->addViolation();
}
}
if (!$constraint->allowExtraFields) {
foreach ($value as $field => $fieldValue) {
if (!isset($constraint->fields[$field])) {
if ($context instanceof ExecutionContextInterface) {
$context->buildViolation($constraint->extraFieldsMessage)
->atPath('['.$field.']')
->setParameter('{{ field }}', $this->formatValue($field))
->setInvalidValue($fieldValue)
->setCode(Collection::NO_SUCH_FIELD_ERROR)
->addViolation();
} else {
$this->buildViolationInContext($context, $constraint->extraFieldsMessage)
->atPath('['.$field.']')
->setParameter('{{ field }}', $this->formatValue($field))
->setInvalidValue($fieldValue)
->setCode(Collection::NO_SUCH_FIELD_ERROR)
->addViolation();
}
$context->buildViolation($constraint->extraFieldsMessage)
->atPath('['.$field.']')
->setParameter('{{ field }}', $this->formatValue($field))
->setInvalidValue($fieldValue)
->setCode(Collection::NO_SUCH_FIELD_ERROR)
->addViolation();
}
}
}
@@ -204,11 +204,6 @@ protected function buildViolation($message)
return new ConstraintViolationAssertion($this->context, $message, $this->constraint);
}
protected function getApiVersion()
{
return Validation::API_VERSION_2_5;
}
abstract protected function createValidator();
}
@@ -19,11 +19,6 @@
class AllValidatorTest extends AbstractConstraintValidatorTest
{
protected function getApiVersion()
{
return Validation::API_VERSION_2_5;
}
protected function createValidator()
{
return new AllValidator();
@@ -17,11 +17,6 @@
class BlankValidatorTest extends AbstractConstraintValidatorTest
{
protected function getApiVersion()
{
return Validation::API_VERSION_2_5;
}
protected function createValidator()
{
return new BlankValidator();
@@ -46,11 +46,6 @@ public static function validateStatic($object, ExecutionContextInterface $contex
class CallbackValidatorTest extends AbstractConstraintValidatorTest
{
protected function getApiVersion()
{
return Validation::API_VERSION_2_5;
}
protected function createValidator()
{
return new CallbackValidator();
@@ -17,11 +17,6 @@
class CardSchemeValidatorTest extends AbstractConstraintValidatorTest
{
protected function getApiVersion()
{
return Validation::API_VERSION_2_5;
}
protected function createValidator()
{
return new CardSchemeValidator();
@@ -22,11 +22,6 @@ function choice_callback()
class ChoiceValidatorTest extends AbstractConstraintValidatorTest
{
protected function getApiVersion()
{
return Validation::API_VERSION_2_5;
}
protected function createValidator()
{
return new ChoiceValidator();
@@ -21,11 +21,6 @@
abstract class CollectionValidatorTest extends AbstractConstraintValidatorTest
{
protected function getApiVersion()
{
return Validation::API_VERSION_2_5;
}
protected function createValidator()
{
return new CollectionValidator();
@@ -20,11 +20,6 @@
*/
abstract class CountValidatorTest extends AbstractConstraintValidatorTest
{
protected function getApiVersion()
{
return Validation::API_VERSION_2_5;
}
protected function createValidator()
{
return new CountValidator();
@@ -18,11 +18,6 @@
class CountryValidatorTest extends AbstractConstraintValidatorTest
{
protected function getApiVersion()
{
return Validation::API_VERSION_2_5;
}
protected function createValidator()
{
return new CountryValidator();
@@ -18,11 +18,6 @@
class CurrencyValidatorTest extends AbstractConstraintValidatorTest
{
protected function getApiVersion()
{
return Validation::API_VERSION_2_5;
}
protected function createValidator()
{
return new CurrencyValidator();
@@ -17,11 +17,6 @@
class DateTimeValidatorTest extends AbstractConstraintValidatorTest
{
protected function getApiVersion()
{
return Validation::API_VERSION_2_5;
}
protected function createValidator()
{
return new DateTimeValidator();
@@ -17,11 +17,6 @@
class DateValidatorTest extends AbstractConstraintValidatorTest
{
protected function getApiVersion()
{
return Validation::API_VERSION_2_5;
}
protected function createValidator()
{
return new DateValidator();
@@ -17,11 +17,6 @@
class EmailValidatorTest extends AbstractConstraintValidatorTest
{
protected function getApiVersion()
{
return Validation::API_VERSION_2_5;
}
protected function createValidator()
{
return new EmailValidator(false);
@@ -20,11 +20,6 @@
*/
class EqualToValidatorTest extends AbstractComparisonValidatorTestCase
{
protected function getApiVersion()
{
return Validation::API_VERSION_2_5;
}
protected function createValidator()
{
return new EqualToValidator();
@@ -19,11 +19,6 @@
class ExpressionValidatorTest extends AbstractConstraintValidatorTest
{
protected function getApiVersion()
{
return Validation::API_VERSION_2_5;
}
protected function createValidator()
{
return new ExpressionValidator(PropertyAccess::createPropertyAccessor());
@@ -22,11 +22,6 @@
protected $file;
protected function getApiVersion()
{
return Validation::API_VERSION_2_5;
}
protected function createValidator()
{
return new FileValidator();
@@ -20,11 +20,6 @@
*/
class GreaterThanOrEqualValidatorTest extends AbstractComparisonValidatorTestCase
{
protected function getApiVersion()
{
return Validation::API_VERSION_2_5;
}
protected function createValidator()
{
return new GreaterThanOrEqualValidator();
@@ -20,11 +20,6 @@
*/
class GreaterThanValidatorTest extends AbstractComparisonValidatorTestCase
{
protected function getApiVersion()
{
return Validation::API_VERSION_2_5;
}
protected function createValidator()
{
return new GreaterThanValidator();
@@ -17,11 +17,6 @@
class IbanValidatorTest extends AbstractConstraintValidatorTest
{
protected function getApiVersion()
{
return Validation::API_VERSION_2_5;
}
protected function createValidator()
{
return new IbanValidator();
@@ -20,11 +20,6 @@
*/
class IdenticalToValidatorTest extends AbstractComparisonValidatorTestCase
{
protected function getApiVersion()
{
return Validation::API_VERSION_2_5;
}
protected function createValidator()
{
return new IdenticalToValidator();
@@ -33,11 +33,6 @@ class ImageValidatorTest extends AbstractConstraintValidatorTest
protected $imagePortrait;
protected $image4By3;
protected function getApiVersion()
{
return Validation::API_VERSION_2_5;
}
protected function createValidator()
{
return new ImageValidator();
Oops, something went wrong.

1 comment on commit 8fd32ba

@SoboLAN

This comment has been minimized.

Show comment
Hide comment
@SoboLAN

SoboLAN Oct 12, 2015

This commit is the most beatiful thing I've seen today. That whole API_VERSION thing was kind of a pain-in-the-ass.

Really awesome job 👍

SoboLAN commented on 8fd32ba Oct 12, 2015

This commit is the most beatiful thing I've seen today. That whole API_VERSION thing was kind of a pain-in-the-ass.

Really awesome job 👍

Please sign in to comment.