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