Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\Validator\Constraints; Chris@0: Chris@0: use Symfony\Component\Validator\Constraint; Chris@0: Chris@0: /** Chris@0: * @Annotation Chris@0: * Chris@0: * @author Colin O'Dell Chris@0: * @author Bernhard Schussek Chris@0: */ Chris@0: class Uuid extends Constraint Chris@0: { Chris@0: const TOO_SHORT_ERROR = 'aa314679-dac9-4f54-bf97-b2049df8f2a3'; Chris@0: const TOO_LONG_ERROR = '494897dd-36f8-4d31-8923-71a8d5f3000d'; Chris@0: const INVALID_CHARACTERS_ERROR = '51120b12-a2bc-41bf-aa53-cd73daf330d0'; Chris@0: const INVALID_HYPHEN_PLACEMENT_ERROR = '98469c83-0309-4f5d-bf95-a496dcaa869c'; Chris@0: const INVALID_VERSION_ERROR = '21ba13b4-b185-4882-ac6f-d147355987eb'; Chris@0: const INVALID_VARIANT_ERROR = '164ef693-2b9d-46de-ad7f-836201f0c2db'; Chris@0: Chris@17: protected static $errorNames = [ Chris@0: self::TOO_SHORT_ERROR => 'TOO_SHORT_ERROR', Chris@0: self::TOO_LONG_ERROR => 'TOO_LONG_ERROR', Chris@0: self::INVALID_CHARACTERS_ERROR => 'INVALID_CHARACTERS_ERROR', Chris@0: self::INVALID_HYPHEN_PLACEMENT_ERROR => 'INVALID_HYPHEN_PLACEMENT_ERROR', Chris@0: self::INVALID_VERSION_ERROR => 'INVALID_VERSION_ERROR', Chris@0: self::INVALID_VARIANT_ERROR => 'INVALID_VARIANT_ERROR', Chris@17: ]; Chris@0: Chris@0: // Possible versions defined by RFC 4122 Chris@0: const V1_MAC = 1; Chris@0: const V2_DCE = 2; Chris@0: const V3_MD5 = 3; Chris@0: const V4_RANDOM = 4; Chris@0: const V5_SHA1 = 5; Chris@0: Chris@0: /** Chris@0: * Message to display when validation fails. Chris@0: * Chris@0: * @var string Chris@0: */ Chris@0: public $message = 'This is not a valid UUID.'; Chris@0: Chris@0: /** Chris@0: * Strict mode only allows UUIDs that meet the formal definition and formatting per RFC 4122. Chris@0: * Chris@0: * Set this to `false` to allow legacy formats with different dash positioning or wrapping characters Chris@0: * Chris@0: * @var bool Chris@0: */ Chris@0: public $strict = true; Chris@0: Chris@0: /** Chris@0: * Array of allowed versions (see version constants above). Chris@0: * Chris@0: * All UUID versions are allowed by default Chris@0: * Chris@0: * @var int[] Chris@0: */ Chris@17: public $versions = [ Chris@0: self::V1_MAC, Chris@0: self::V2_DCE, Chris@0: self::V3_MD5, Chris@0: self::V4_RANDOM, Chris@0: self::V5_SHA1, Chris@17: ]; Chris@0: }