This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Validator/Constraints/Uuid.php

78 lines
2.0 KiB
PHP
Raw Normal View History

2014-02-18 20:53:41 +00:00
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Constraint;
/**
* @Annotation
*
* @author Colin O'Dell <colinodell@gmail.com>
* @author Bernhard Schussek <bschussek@gmail.com>
2014-02-18 20:53:41 +00:00
*/
class Uuid extends Constraint
{
const TOO_SHORT_ERROR = 1;
const TOO_LONG_ERROR = 2;
const INVALID_CHARACTERS_ERROR = 3;
const INVALID_HYPHEN_PLACEMENT_ERROR = 4;
const INVALID_VERSION_ERROR = 5;
const INVALID_VARIANT_ERROR = 6;
protected static $errorNames = array(
self::TOO_SHORT_ERROR => 'TOO_SHORT_ERROR',
self::TOO_LONG_ERROR => 'TOO_LONG_ERROR',
self::INVALID_CHARACTERS_ERROR => 'INVALID_CHARACTERS_ERROR',
self::INVALID_HYPHEN_PLACEMENT_ERROR => 'INVALID_HYPHEN_PLACEMENT_ERROR',
self::INVALID_VERSION_ERROR => 'INVALID_VERSION_ERROR',
self::INVALID_VARIANT_ERROR => 'INVALID_VARIANT_ERROR',
);
2014-02-18 20:53:41 +00:00
// Possible versions defined by RFC 4122
const V1_MAC = 1;
const V2_DCE = 2;
const V3_MD5 = 3;
const V4_RANDOM = 4;
const V5_SHA1 = 5;
/**
2015-08-24 07:53:33 +01:00
* Message to display when validation fails.
2014-02-18 20:53:41 +00:00
*
* @var string
*/
public $message = 'This is not a valid UUID.';
/**
2015-08-24 07:53:33 +01:00
* Strict mode only allows UUIDs that meet the formal definition and formatting per RFC 4122.
2014-02-18 20:53:41 +00:00
*
* Set this to `false` to allow legacy formats with different dash positioning or wrapping characters
*
* @var bool
*/
public $strict = true;
/**
2015-08-24 07:53:33 +01:00
* Array of allowed versions (see version constants above).
2014-02-18 20:53:41 +00:00
*
* All UUID versions are allowed by default
*
* @var int[]
*/
public $versions = array(
self::V1_MAC,
self::V2_DCE,
self::V3_MD5,
self::V4_RANDOM,
Merge branch '2.4' into 2.5 * 2.4: fixed CS [Process] fixed some volatile tests [HttpKernel] fixed a volatile test [HttpFoundation] fixed some volatile tests [Tests] PHPUnit Optimizations Use getPathname() instead of string casting to get BinaryFileReponse file path Conflicts: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SessionController.php src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php src/Symfony/Component/Process/Tests/AbstractProcessTest.php src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php src/Symfony/Component/Security/Core/Authentication/Provider/PreAuthenticatedAuthenticationProvider.php src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php src/Symfony/Component/Translation/Tests/Dumper/IcuResFileDumperTest.php src/Symfony/Component/Validator/Constraints/ChoiceValidator.php src/Symfony/Component/Validator/Constraints/CollectionValidator.php src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php src/Symfony/Component/Validator/Tests/ValidationVisitorTest.php src/Symfony/Component/Yaml/Parser.php
2014-09-22 10:14:18 +01:00
self::V5_SHA1,
2014-02-18 20:53:41 +00:00
);
}