4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Validator\Constraints;
14 use Symfony\Component\Validator\Constraint;
19 * @author Colin O'Dell <colinodell@gmail.com>
20 * @author Bernhard Schussek <bschussek@gmail.com>
22 class Uuid extends Constraint
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';
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',
40 // Possible versions defined by RFC 4122
48 * Message to display when validation fails.
52 public $message = 'This is not a valid UUID.';
55 * Strict mode only allows UUIDs that meet the formal definition and formatting per RFC 4122.
57 * Set this to `false` to allow legacy formats with different dash positioning or wrapping characters
61 public $strict = true;
64 * Array of allowed versions (see version constants above).
66 * All UUID versions are allowed by default
70 public $versions = array(