annotate vendor/symfony/validator/Constraints/Uuid.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 129ea1e6d783
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 /*
Chris@0 4 * This file is part of the Symfony package.
Chris@0 5 *
Chris@0 6 * (c) Fabien Potencier <fabien@symfony.com>
Chris@0 7 *
Chris@0 8 * For the full copyright and license information, please view the LICENSE
Chris@0 9 * file that was distributed with this source code.
Chris@0 10 */
Chris@0 11
Chris@0 12 namespace Symfony\Component\Validator\Constraints;
Chris@0 13
Chris@0 14 use Symfony\Component\Validator\Constraint;
Chris@0 15
Chris@0 16 /**
Chris@0 17 * @Annotation
Chris@0 18 *
Chris@0 19 * @author Colin O'Dell <colinodell@gmail.com>
Chris@0 20 * @author Bernhard Schussek <bschussek@gmail.com>
Chris@0 21 */
Chris@0 22 class Uuid extends Constraint
Chris@0 23 {
Chris@0 24 const TOO_SHORT_ERROR = 'aa314679-dac9-4f54-bf97-b2049df8f2a3';
Chris@0 25 const TOO_LONG_ERROR = '494897dd-36f8-4d31-8923-71a8d5f3000d';
Chris@0 26 const INVALID_CHARACTERS_ERROR = '51120b12-a2bc-41bf-aa53-cd73daf330d0';
Chris@0 27 const INVALID_HYPHEN_PLACEMENT_ERROR = '98469c83-0309-4f5d-bf95-a496dcaa869c';
Chris@0 28 const INVALID_VERSION_ERROR = '21ba13b4-b185-4882-ac6f-d147355987eb';
Chris@0 29 const INVALID_VARIANT_ERROR = '164ef693-2b9d-46de-ad7f-836201f0c2db';
Chris@0 30
Chris@17 31 protected static $errorNames = [
Chris@0 32 self::TOO_SHORT_ERROR => 'TOO_SHORT_ERROR',
Chris@0 33 self::TOO_LONG_ERROR => 'TOO_LONG_ERROR',
Chris@0 34 self::INVALID_CHARACTERS_ERROR => 'INVALID_CHARACTERS_ERROR',
Chris@0 35 self::INVALID_HYPHEN_PLACEMENT_ERROR => 'INVALID_HYPHEN_PLACEMENT_ERROR',
Chris@0 36 self::INVALID_VERSION_ERROR => 'INVALID_VERSION_ERROR',
Chris@0 37 self::INVALID_VARIANT_ERROR => 'INVALID_VARIANT_ERROR',
Chris@17 38 ];
Chris@0 39
Chris@0 40 // Possible versions defined by RFC 4122
Chris@0 41 const V1_MAC = 1;
Chris@0 42 const V2_DCE = 2;
Chris@0 43 const V3_MD5 = 3;
Chris@0 44 const V4_RANDOM = 4;
Chris@0 45 const V5_SHA1 = 5;
Chris@0 46
Chris@0 47 /**
Chris@0 48 * Message to display when validation fails.
Chris@0 49 *
Chris@0 50 * @var string
Chris@0 51 */
Chris@0 52 public $message = 'This is not a valid UUID.';
Chris@0 53
Chris@0 54 /**
Chris@0 55 * Strict mode only allows UUIDs that meet the formal definition and formatting per RFC 4122.
Chris@0 56 *
Chris@0 57 * Set this to `false` to allow legacy formats with different dash positioning or wrapping characters
Chris@0 58 *
Chris@0 59 * @var bool
Chris@0 60 */
Chris@0 61 public $strict = true;
Chris@0 62
Chris@0 63 /**
Chris@0 64 * Array of allowed versions (see version constants above).
Chris@0 65 *
Chris@0 66 * All UUID versions are allowed by default
Chris@0 67 *
Chris@0 68 * @var int[]
Chris@0 69 */
Chris@17 70 public $versions = [
Chris@0 71 self::V1_MAC,
Chris@0 72 self::V2_DCE,
Chris@0 73 self::V3_MD5,
Chris@0 74 self::V4_RANDOM,
Chris@0 75 self::V5_SHA1,
Chris@17 76 ];
Chris@0 77 }