vendor/symfony/validator/Validator/ValidatorInterface.php line 53

  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\Validator;
  11. use Symfony\Component\Validator\Constraint;
  12. use Symfony\Component\Validator\Constraints\GroupSequence;
  13. use Symfony\Component\Validator\ConstraintViolationListInterface;
  14. use Symfony\Component\Validator\Context\ExecutionContextInterface;
  15. use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface;
  16. /**
  17.  * Validates PHP values against constraints.
  18.  *
  19.  * @author Bernhard Schussek <bschussek@gmail.com>
  20.  */
  21. interface ValidatorInterface extends MetadataFactoryInterface
  22. {
  23.     /**
  24.      * Validates a value against a constraint or a list of constraints.
  25.      *
  26.      * If no constraint is passed, the constraint
  27.      * {@link \Symfony\Component\Validator\Constraints\Valid} is assumed.
  28.      *
  29.      * @param Constraint|Constraint[]                               $constraints The constraint(s) to validate against
  30.      * @param string|GroupSequence|array<string|GroupSequence>|null $groups      The validation groups to validate. If none is given, "Default" is assumed
  31.      *
  32.      * @return ConstraintViolationListInterface A list of constraint violations
  33.      *                                          If the list is empty, validation
  34.      *                                          succeeded
  35.      */
  36.     public function validate(mixed $valueConstraint|array $constraints nullstring|GroupSequence|array $groups null): ConstraintViolationListInterface;
  37.     /**
  38.      * Validates a property of an object against the constraints specified
  39.      * for this property.
  40.      *
  41.      * @param string                                                $propertyName The name of the validated property
  42.      * @param string|GroupSequence|array<string|GroupSequence>|null $groups       The validation groups to validate. If none is given, "Default" is assumed
  43.      *
  44.      * @return ConstraintViolationListInterface A list of constraint violations
  45.      *                                          If the list is empty, validation
  46.      *                                          succeeded
  47.      */
  48.     public function validateProperty(object $objectstring $propertyNamestring|GroupSequence|array $groups null): ConstraintViolationListInterface;
  49.     /**
  50.      * Validates a value against the constraints specified for an object's
  51.      * property.
  52.      *
  53.      * @param object|string                                         $objectOrClass The object or its class name
  54.      * @param string                                                $propertyName  The name of the property
  55.      * @param mixed                                                 $value         The value to validate against the property's constraints
  56.      * @param string|GroupSequence|array<string|GroupSequence>|null $groups        The validation groups to validate. If none is given, "Default" is assumed
  57.      *
  58.      * @return ConstraintViolationListInterface A list of constraint violations
  59.      *                                          If the list is empty, validation
  60.      *                                          succeeded
  61.      */
  62.     public function validatePropertyValue(object|string $objectOrClassstring $propertyNamemixed $valuestring|GroupSequence|array $groups null): ConstraintViolationListInterface;
  63.     /**
  64.      * Starts a new validation context and returns a validator for that context.
  65.      *
  66.      * The returned validator collects all violations generated within its
  67.      * context. You can access these violations with the
  68.      * {@link ContextualValidatorInterface::getViolations()} method.
  69.      */
  70.     public function startContext(): ContextualValidatorInterface;
  71.     /**
  72.      * Returns a validator in the given execution context.
  73.      *
  74.      * The returned validator adds all generated violations to the given
  75.      * context.
  76.      */
  77.     public function inContext(ExecutionContextInterface $context): ContextualValidatorInterface;
  78. }