Isbn.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 The Whole Life To Learn <thewholelifetolearn@gmail.com>
  17. * @author Manuel Reinhard <manu@sprain.ch>
  18. * @author Bernhard Schussek <bschussek@gmail.com>
  19. */
  20. class Isbn extends Constraint
  21. {
  22. const TOO_SHORT_ERROR = '949acbb0-8ef5-43ed-a0e9-032dfd08ae45';
  23. const TOO_LONG_ERROR = '3171387d-f80a-47b3-bd6e-60598545316a';
  24. const INVALID_CHARACTERS_ERROR = '23d21cea-da99-453d-98b1-a7d916fbb339';
  25. const CHECKSUM_FAILED_ERROR = '2881c032-660f-46b6-8153-d352d9706640';
  26. const TYPE_NOT_RECOGNIZED_ERROR = 'fa54a457-f042-441f-89c4-066ee5bdd3e1';
  27. protected static $errorNames = array(
  28. self::TOO_SHORT_ERROR => 'TOO_SHORT_ERROR',
  29. self::TOO_LONG_ERROR => 'TOO_LONG_ERROR',
  30. self::INVALID_CHARACTERS_ERROR => 'INVALID_CHARACTERS_ERROR',
  31. self::CHECKSUM_FAILED_ERROR => 'CHECKSUM_FAILED_ERROR',
  32. self::TYPE_NOT_RECOGNIZED_ERROR => 'TYPE_NOT_RECOGNIZED_ERROR',
  33. );
  34. public $isbn10Message = 'This value is not a valid ISBN-10.';
  35. public $isbn13Message = 'This value is not a valid ISBN-13.';
  36. public $bothIsbnMessage = 'This value is neither a valid ISBN-10 nor a valid ISBN-13.';
  37. public $type;
  38. public $message;
  39. /**
  40. * @deprecated since version 2.5, to be removed in 3.0. Use option "type" instead.
  41. *
  42. * @var bool
  43. */
  44. public $isbn10 = false;
  45. /**
  46. * @deprecated since version 2.5, to be removed in 3.0. Use option "type" instead.
  47. *
  48. * @var bool
  49. */
  50. public $isbn13 = false;
  51. /**
  52. * {@inheritdoc}
  53. */
  54. public function getDefaultOption()
  55. {
  56. return 'type';
  57. }
  58. }