Isin.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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\Validator\Constraint;
  12. /**
  13. * @Annotation
  14. * @Target({"PROPERTY", "METHOD", "ANNOTATION"})
  15. *
  16. * @author Laurent Masforné <l.masforne@gmail.com>
  17. */
  18. #[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
  19. class Isin extends Constraint
  20. {
  21. public const VALIDATION_LENGTH = 12;
  22. public const VALIDATION_PATTERN = '/[A-Z]{2}[A-Z0-9]{9}[0-9]{1}/';
  23. public const INVALID_LENGTH_ERROR = '88738dfc-9ed5-ba1e-aebe-402a2a9bf58e';
  24. public const INVALID_PATTERN_ERROR = '3d08ce0-ded9-a93d-9216-17ac21265b65e';
  25. public const INVALID_CHECKSUM_ERROR = '32089b-0ee1-93ba-399e-aa232e62f2d29d';
  26. protected static $errorNames = [
  27. self::INVALID_LENGTH_ERROR => 'INVALID_LENGTH_ERROR',
  28. self::INVALID_PATTERN_ERROR => 'INVALID_PATTERN_ERROR',
  29. self::INVALID_CHECKSUM_ERROR => 'INVALID_CHECKSUM_ERROR',
  30. ];
  31. public $message = 'This value is not a valid International Securities Identification Number (ISIN).';
  32. public function __construct(array $options = null, string $message = null, array $groups = null, $payload = null)
  33. {
  34. parent::__construct($options, $groups, $payload);
  35. $this->message = $message ?? $this->message;
  36. }
  37. }