vendor/symfony/validator/Constraints/Locale.php line 25

Open in your IDE?
  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\Constraints;
  11. use Symfony\Component\Intl\Locales;
  12. use Symfony\Component\Validator\Constraint;
  13. use Symfony\Component\Validator\Exception\LogicException;
  14. /**
  15.  * @Annotation
  16.  * @Target({"PROPERTY", "METHOD", "ANNOTATION"})
  17.  *
  18.  * @author Bernhard Schussek <bschussek@gmail.com>
  19.  */
  20. #[\Attribute(\Attribute::TARGET_PROPERTY \Attribute::TARGET_METHOD \Attribute::IS_REPEATABLE)]
  21. class Locale extends Constraint
  22. {
  23.     public const NO_SUCH_LOCALE_ERROR 'a0af4293-1f1a-4a1c-a328-979cba6182a2';
  24.     protected static $errorNames = [
  25.         self::NO_SUCH_LOCALE_ERROR => 'NO_SUCH_LOCALE_ERROR',
  26.     ];
  27.     public $message 'This value is not a valid locale.';
  28.     public $canonicalize true;
  29.     public function __construct(
  30.         array $options null,
  31.         string $message null,
  32.         bool $canonicalize null,
  33.         array $groups null,
  34.         $payload null
  35.     ) {
  36.         if (!class_exists(Locales::class)) {
  37.             throw new LogicException('The Intl component is required to use the Locale constraint. Try running "composer require symfony/intl".');
  38.         }
  39.         parent::__construct($options$groups$payload);
  40.         $this->message $message ?? $this->message;
  41.         $this->canonicalize $canonicalize ?? $this->canonicalize;
  42.     }
  43. }