Issn.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 Antonio J. García Lagar <aj@garcialagar.es>
  17. * @author Bernhard Schussek <bschussek@gmail.com>
  18. */
  19. #[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
  20. class Issn extends Constraint
  21. {
  22. public const TOO_SHORT_ERROR = '6a20dd3d-f463-4460-8e7b-18a1b98abbfb';
  23. public const TOO_LONG_ERROR = '37cef893-5871-464e-8b12-7fb79324833c';
  24. public const MISSING_HYPHEN_ERROR = '2983286f-8134-4693-957a-1ec4ef887b15';
  25. public const INVALID_CHARACTERS_ERROR = 'a663d266-37c2-4ece-a914-ae891940c588';
  26. public const INVALID_CASE_ERROR = '7b6dd393-7523-4a6c-b84d-72b91bba5e1a';
  27. public const CHECKSUM_FAILED_ERROR = 'b0f92dbc-667c-48de-b526-ad9586d43e85';
  28. protected static $errorNames = [
  29. self::TOO_SHORT_ERROR => 'TOO_SHORT_ERROR',
  30. self::TOO_LONG_ERROR => 'TOO_LONG_ERROR',
  31. self::MISSING_HYPHEN_ERROR => 'MISSING_HYPHEN_ERROR',
  32. self::INVALID_CHARACTERS_ERROR => 'INVALID_CHARACTERS_ERROR',
  33. self::INVALID_CASE_ERROR => 'INVALID_CASE_ERROR',
  34. self::CHECKSUM_FAILED_ERROR => 'CHECKSUM_FAILED_ERROR',
  35. ];
  36. public $message = 'This value is not a valid ISSN.';
  37. public $caseSensitive = false;
  38. public $requireHyphen = false;
  39. public function __construct(
  40. array $options = null,
  41. string $message = null,
  42. bool $caseSensitive = null,
  43. bool $requireHyphen = null,
  44. array $groups = null,
  45. $payload = null
  46. ) {
  47. parent::__construct($options, $groups, $payload);
  48. $this->message = $message ?? $this->message;
  49. $this->caseSensitive = $caseSensitive ?? $this->caseSensitive;
  50. $this->requireHyphen = $requireHyphen ?? $this->requireHyphen;
  51. }
  52. }