class Uuid
Same name in this branch
- 11.1.x vendor/ramsey/uuid/src/Nonstandard/Uuid.php \Ramsey\Uuid\Nonstandard\Uuid
- 11.1.x vendor/ramsey/uuid/src/Uuid.php \Ramsey\Uuid\Uuid
- 11.1.x core/lib/Drupal/Component/Uuid/Uuid.php \Drupal\Component\Uuid\Uuid
Validates that a value is a valid Universally unique identifier (UUID).
@author Colin O'Dell <colinodell@gmail.com> @author Bernhard Schussek <bschussek@gmail.com>
Hierarchy
- class \Symfony\Component\Validator\Constraint
- class \Symfony\Component\Validator\Constraints\Uuid extends \Symfony\Component\Validator\Constraint
Expanded class hierarchy of Uuid
See also
https://en.wikipedia.org/wiki/Universally_unique_identifier
https://datatracker.ietf.org/doc/html/rfc4122
1 file declares its use of Uuid
- UuidConstraint.php in core/
lib/ Drupal/ Core/ Validation/ Plugin/ Validation/ Constraint/ UuidConstraint.php
55 string references to 'Uuid'
- BaseFieldOverrideStorage::createInstance in core/
lib/ Drupal/ Core/ Field/ BaseFieldOverrideStorage.php - Instantiates a new instance of this entity handler.
- CKEditor5MediaController::access in core/
modules/ ckeditor5/ src/ Controller/ CKEditor5MediaController.php - Additional access check for ::isMediaImage().
- CKEditor5MediaController::mediaEntityMetadata in core/
modules/ ckeditor5/ src/ Controller/ CKEditor5MediaController.php - Returns JSON response containing metadata about media entity.
- CommentAccessControlHandler::checkFieldAccess in core/
modules/ comment/ src/ CommentAccessControlHandler.php - Default field access as determined by this access control handler.
- CommentTokensHooks::tokenInfo in core/
modules/ comment/ src/ Hook/ CommentTokensHooks.php - Implements hook_token_info().
File
-
vendor/
symfony/ validator/ Constraints/ Uuid.php, line 26
Namespace
Symfony\Component\Validator\ConstraintsView source
class Uuid extends Constraint {
public const TOO_SHORT_ERROR = 'aa314679-dac9-4f54-bf97-b2049df8f2a3';
public const TOO_LONG_ERROR = '494897dd-36f8-4d31-8923-71a8d5f3000d';
public const INVALID_CHARACTERS_ERROR = '51120b12-a2bc-41bf-aa53-cd73daf330d0';
public const INVALID_HYPHEN_PLACEMENT_ERROR = '98469c83-0309-4f5d-bf95-a496dcaa869c';
public const INVALID_VERSION_ERROR = '21ba13b4-b185-4882-ac6f-d147355987eb';
public const INVALID_TIME_BASED_VERSION_ERROR = '484081ca-6fbd-11ed-ade8-a3bdfd0fcf2f';
public const INVALID_VARIANT_ERROR = '164ef693-2b9d-46de-ad7f-836201f0c2db';
protected const ERROR_NAMES = [
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',
];
// Possible versions defined by RFC 9562/4122
public const V1_MAC = 1;
public const V2_DCE = 2;
public const V3_MD5 = 3;
public const V4_RANDOM = 4;
public const V5_SHA1 = 5;
public const V6_SORTABLE = 6;
public const V7_MONOTONIC = 7;
public const V8_CUSTOM = 8;
public const ALL_VERSIONS = [
self::V1_MAC,
self::V2_DCE,
self::V3_MD5,
self::V4_RANDOM,
self::V5_SHA1,
self::V6_SORTABLE,
self::V7_MONOTONIC,
self::V8_CUSTOM,
];
public const TIME_BASED_VERSIONS = [
self::V1_MAC,
self::V6_SORTABLE,
self::V7_MONOTONIC,
];
/**
* Message to display when validation fails.
*/
public string $message = 'This is not a valid UUID.';
/**
* Strict mode only allows UUIDs that meet the formal definition and formatting per RFC 9562/4122.
*
* Set this to `false` to allow legacy formats with different dash positioning or wrapping characters
*/
public bool $strict = true;
/**
* Array of allowed versions (see version constants above).
*
* All UUID versions are allowed by default
*
* @var int[]
*/
public array $versions = self::ALL_VERSIONS;
/** @var callable|null */
public $normalizer;
/**
* @param array<string,mixed>|null $options
* @param self::V*[]|self::V*|null $versions Specific UUID versions (defaults to {@see Uuid::ALL_VERSIONS})
* @param bool|null $strict Whether to force the value to follow the RFC's input format rules; pass false to allow alternate formats (defaults to true)
* @param string[]|null $groups
*/
public function __construct(?array $options = null, ?string $message = null, array|int|null $versions = null, ?bool $strict = null, ?callable $normalizer = null, ?array $groups = null, mixed $payload = null) {
parent::__construct($options, $groups, $payload);
$this->message = $message ?? $this->message;
$this->versions = (array) ($versions ?? $this->versions);
$this->strict = $strict ?? $this->strict;
$this->normalizer = $normalizer ?? $this->normalizer;
if (null !== $this->normalizer && !\is_callable($this->normalizer)) {
throw new InvalidArgumentException(\sprintf('The "normalizer" option must be a valid callable ("%s" given).', get_debug_type($this->normalizer)));
}
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
Constraint::$groups | public | property | The groups that the constraint belongs to. | ||
Constraint::$payload | public | property | Domain-specific data attached to a constraint. | ||
Constraint::addImplicitGroupName | public | function | Adds the given group if this constraint is in the Default group. | 2 | |
Constraint::CLASS_CONSTRAINT | public | constant | Marks a constraint that can be put onto classes. | ||
Constraint::DEFAULT_GROUP | public | constant | The name of the group given to all constraints with no explicit group. | ||
Constraint::getDefaultOption | public | function | Returns the name of the default option. | 28 | |
Constraint::getErrorName | public static | function | Returns the name of the given error code. | ||
Constraint::getRequiredOptions | public | function | Returns the name of the required options. | 22 | |
Constraint::getTargets | public | function | Returns whether the constraint can be put onto classes, properties or both. |
8 | |
Constraint::normalizeOptions | protected | function | |||
Constraint::PROPERTY_CONSTRAINT | public | constant | Marks a constraint that can be put onto properties. | ||
Constraint::validatedBy | public | function | Returns the name of the class that validates this constraint. | 9 | |
Constraint::__get | public | function | Returns the value of a lazily initialized option. | 2 | |
Constraint::__isset | public | function | 1 | ||
Constraint::__set | public | function | Sets the value of a lazily initialized option. | 1 | |
Constraint::__sleep | public | function | Optimizes the serialized value to minimize storage space. | ||
Uuid::$message | public | property | Message to display when validation fails. | ||
Uuid::$normalizer | public | property | @var callable|null | ||
Uuid::$strict | public | property | Strict mode only allows UUIDs that meet the formal definition and formatting per RFC 9562/4122. | ||
Uuid::$versions | public | property | Array of allowed versions (see version constants above). | ||
Uuid::ALL_VERSIONS | public | constant | |||
Uuid::ERROR_NAMES | protected | constant | Maps error codes to the names of their constants. | Overrides Constraint::ERROR_NAMES | |
Uuid::INVALID_CHARACTERS_ERROR | public | constant | |||
Uuid::INVALID_HYPHEN_PLACEMENT_ERROR | public | constant | |||
Uuid::INVALID_TIME_BASED_VERSION_ERROR | public | constant | |||
Uuid::INVALID_VARIANT_ERROR | public | constant | |||
Uuid::INVALID_VERSION_ERROR | public | constant | |||
Uuid::TIME_BASED_VERSIONS | public | constant | |||
Uuid::TOO_LONG_ERROR | public | constant | |||
Uuid::TOO_SHORT_ERROR | public | constant | |||
Uuid::V1_MAC | public | constant | |||
Uuid::V2_DCE | public | constant | |||
Uuid::V3_MD5 | public | constant | |||
Uuid::V4_RANDOM | public | constant | |||
Uuid::V5_SHA1 | public | constant | |||
Uuid::V6_SORTABLE | public | constant | |||
Uuid::V7_MONOTONIC | public | constant | |||
Uuid::V8_CUSTOM | public | constant | |||
Uuid::__construct | public | function | Overrides Constraint::__construct |