ValidatorInterface.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Validator;
  11. /**
  12. * Validates values and graphs of objects and arrays.
  13. *
  14. * @author Bernhard Schussek <bschussek@gmail.com>
  15. *
  16. * @deprecated since version 2.5, to be removed in 3.0.
  17. * Use {@link \Symfony\Component\Validator\Validator\ValidatorInterface} instead.
  18. */
  19. interface ValidatorInterface
  20. {
  21. /**
  22. * Validates a value.
  23. *
  24. * The accepted values depend on the {@link MetadataFactoryInterface}
  25. * implementation.
  26. *
  27. * The signature changed with Symfony 2.5 (see
  28. * {@link Validator\ValidatorInterface::validate()}. This signature will be
  29. * disabled in Symfony 3.0.
  30. *
  31. * @param mixed $value The value to validate
  32. * @param array|null $groups The validation groups to validate
  33. * @param bool $traverse Whether to traverse the value if it is traversable
  34. * @param bool $deep Whether to traverse nested traversable values recursively
  35. *
  36. * @return ConstraintViolationListInterface A list of constraint violations. If the
  37. * list is empty, validation succeeded.
  38. */
  39. public function validate($value, $groups = null, $traverse = false, $deep = false);
  40. /**
  41. * Validates a property of a value against its current value.
  42. *
  43. * The accepted values depend on the {@link MetadataFactoryInterface}
  44. * implementation.
  45. *
  46. * @param mixed $containingValue The value containing the property
  47. * @param string $property The name of the property to validate
  48. * @param array|null $groups The validation groups to validate
  49. *
  50. * @return ConstraintViolationListInterface A list of constraint violations. If the
  51. * list is empty, validation succeeded.
  52. */
  53. public function validateProperty($containingValue, $property, $groups = null);
  54. /**
  55. * Validate a property of a value against a potential value.
  56. *
  57. * The accepted values depend on the {@link MetadataFactoryInterface}
  58. * implementation.
  59. *
  60. * @param mixed $containingValue The value containing the property
  61. * @param string $property The name of the property to validate
  62. * @param string $value The value to validate against the
  63. * constraints of the property
  64. * @param array|null $groups The validation groups to validate
  65. *
  66. * @return ConstraintViolationListInterface A list of constraint violations. If the
  67. * list is empty, validation succeeded.
  68. */
  69. public function validatePropertyValue($containingValue, $property, $value, $groups = null);
  70. /**
  71. * Validates a value against a constraint or a list of constraints.
  72. *
  73. * @param mixed $value The value to validate
  74. * @param Constraint|Constraint[] $constraints The constraint(s) to validate against
  75. * @param array|null $groups The validation groups to validate
  76. *
  77. * @return ConstraintViolationListInterface A list of constraint violations. If the
  78. * list is empty, validation succeeded.
  79. *
  80. * @deprecated since version 2.5, to be removed in 3.0.
  81. * Renamed to {@link Validator\ValidatorInterface::validate()}
  82. * in Symfony 2.5.
  83. */
  84. public function validateValue($value, $constraints, $groups = null);
  85. /**
  86. * Returns the factory for metadata instances.
  87. *
  88. * @return MetadataFactoryInterface The metadata factory
  89. *
  90. * @deprecated since version 2.5, to be removed in 3.0.
  91. * Use {@link Validator\ValidatorInterface::getMetadataFor()} or
  92. * {@link Validator\ValidatorInterface::hasMetadataFor()}
  93. * instead.
  94. */
  95. public function getMetadataFactory();
  96. }