Uuid
extends Constraint
in package
Contains the properties of a constraint definition.
Tags
Table of Contents
Constants
- ALL_VERSIONS = [self::V1_MAC, self::V2_DCE, self::V3_MD5, self::V4_RANDOM, self::V5_SHA1, self::V6_SORTABLE]
- CLASS_CONSTRAINT = 'class'
- Marks a constraint that can be put onto classes.
- DEFAULT_GROUP = 'Default'
- The name of the group given to all constraints with no explicit group.
- INVALID_CHARACTERS_ERROR = '51120b12-a2bc-41bf-aa53-cd73daf330d0'
- INVALID_HYPHEN_PLACEMENT_ERROR = '98469c83-0309-4f5d-bf95-a496dcaa869c'
- INVALID_VARIANT_ERROR = '164ef693-2b9d-46de-ad7f-836201f0c2db'
- INVALID_VERSION_ERROR = '21ba13b4-b185-4882-ac6f-d147355987eb'
- PROPERTY_CONSTRAINT = 'property'
- Marks a constraint that can be put onto properties.
- TOO_LONG_ERROR = '494897dd-36f8-4d31-8923-71a8d5f3000d'
- TOO_SHORT_ERROR = 'aa314679-dac9-4f54-bf97-b2049df8f2a3'
- V1_MAC = 1
- V2_DCE = 2
- V3_MD5 = 3
- V4_RANDOM = 4
- V5_SHA1 = 5
- V6_SORTABLE = 6
Properties
- $groups : array<string|int, string>
- The groups that the constraint belongs to.
- $message : string
- Message to display when validation fails.
- $normalizer : mixed
- $payload : mixed
- Domain-specific data attached to a constraint.
- $strict : bool
- Strict mode only allows UUIDs that meet the formal definition and formatting per RFC 4122.
- $versions : array<string|int, int>
- Array of allowed versions (see version constants above).
- $errorNames : mixed
- Maps error codes to the names of their constants.
Methods
- __construct() : mixed
- Initializes the constraint with options.
- __get() : mixed
- Returns the value of a lazily initialized option.
- __isset() : bool
- __set() : mixed
- Sets the value of a lazily initialized option.
- addImplicitGroupName() : mixed
- Adds the given group if this constraint is in the Default group.
- getDefaultOption() : string|null
- Returns the name of the default option.
- getErrorName() : string
- Returns the name of the given error code.
- getRequiredOptions() : array<string|int, string>
- Returns the name of the required options.
- getTargets() : string|array<string|int, string>
- Returns whether the constraint can be put onto classes, properties or both.
- validatedBy() : string
- Returns the name of the class that validates this constraint.
- normalizeOptions() : array<string|int, mixed>
Constants
ALL_VERSIONS
public
mixed
ALL_VERSIONS
= [self::V1_MAC, self::V2_DCE, self::V3_MD5, self::V4_RANDOM, self::V5_SHA1, self::V6_SORTABLE]
CLASS_CONSTRAINT
Marks a constraint that can be put onto classes.
public
mixed
CLASS_CONSTRAINT
= 'class'
DEFAULT_GROUP
The name of the group given to all constraints with no explicit group.
public
mixed
DEFAULT_GROUP
= 'Default'
INVALID_CHARACTERS_ERROR
public
mixed
INVALID_CHARACTERS_ERROR
= '51120b12-a2bc-41bf-aa53-cd73daf330d0'
INVALID_HYPHEN_PLACEMENT_ERROR
public
mixed
INVALID_HYPHEN_PLACEMENT_ERROR
= '98469c83-0309-4f5d-bf95-a496dcaa869c'
INVALID_VARIANT_ERROR
public
mixed
INVALID_VARIANT_ERROR
= '164ef693-2b9d-46de-ad7f-836201f0c2db'
INVALID_VERSION_ERROR
public
mixed
INVALID_VERSION_ERROR
= '21ba13b4-b185-4882-ac6f-d147355987eb'
PROPERTY_CONSTRAINT
Marks a constraint that can be put onto properties.
public
mixed
PROPERTY_CONSTRAINT
= 'property'
TOO_LONG_ERROR
public
mixed
TOO_LONG_ERROR
= '494897dd-36f8-4d31-8923-71a8d5f3000d'
TOO_SHORT_ERROR
public
mixed
TOO_SHORT_ERROR
= 'aa314679-dac9-4f54-bf97-b2049df8f2a3'
V1_MAC
public
mixed
V1_MAC
= 1
V2_DCE
public
mixed
V2_DCE
= 2
V3_MD5
public
mixed
V3_MD5
= 3
V4_RANDOM
public
mixed
V4_RANDOM
= 4
V5_SHA1
public
mixed
V5_SHA1
= 5
V6_SORTABLE
public
mixed
V6_SORTABLE
= 6
Properties
$groups
The groups that the constraint belongs to.
public
array<string|int, string>
$groups
$message
Message to display when validation fails.
public
string
$message
= 'This is not a valid UUID.'
$normalizer
public
mixed
$normalizer
$payload
Domain-specific data attached to a constraint.
public
mixed
$payload
$strict
Strict mode only allows UUIDs that meet the formal definition and formatting per RFC 4122.
public
bool
$strict
= true
Set this to false
to allow legacy formats with different dash positioning or wrapping characters
$versions
Array of allowed versions (see version constants above).
public
array<string|int, int>
$versions
= self::ALL_VERSIONS
All UUID versions are allowed by default
$errorNames
Maps error codes to the names of their constants.
protected
static mixed
$errorNames
= [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']
Methods
__construct()
Initializes the constraint with options.
public
__construct([array<string|int, mixed> $options = null ][, string $message = null ][, array<string|int, int>|null $versions = null ][, bool $strict = null ][, callable $normalizer = null ][, array<string|int, mixed> $groups = null ][, mixed $payload = null ]) : mixed
Parameters
- $options : array<string|int, mixed> = null
-
The options (as associative array) or the value for the default option (any other type)
- $message : string = null
- $versions : array<string|int, int>|null = null
- $strict : bool = null
- $normalizer : callable = null
- $groups : array<string|int, mixed> = null
-
An array of validation groups
- $payload : mixed = null
-
Domain-specific data attached to a constraint
__get()
Returns the value of a lazily initialized option.
public
__get(string $option) : mixed
Corresponding properties are added to the object on first access. Hence this method will be called at most once per constraint instance and option name.
Parameters
- $option : string
Tags
__isset()
public
__isset(string $option) : bool
Parameters
- $option : string
Return values
bool__set()
Sets the value of a lazily initialized option.
public
__set(string $option, mixed $value) : mixed
Corresponding properties are added to the object on first access. Hence this method will be called at most once per constraint instance and option name.
Parameters
- $option : string
- $value : mixed
Tags
addImplicitGroupName()
Adds the given group if this constraint is in the Default group.
public
addImplicitGroupName(string $group) : mixed
Parameters
- $group : string
getDefaultOption()
Returns the name of the default option.
public
getDefaultOption() : string|null
Override this method to define a default option.
Tags
Return values
string|nullgetErrorName()
Returns the name of the given error code.
public
static getErrorName(string $errorCode) : string
Parameters
- $errorCode : string
Tags
Return values
stringgetRequiredOptions()
Returns the name of the required options.
public
getRequiredOptions() : array<string|int, string>
Override this method if you want to define required options.
Tags
Return values
array<string|int, string>getTargets()
Returns whether the constraint can be put onto classes, properties or both.
public
getTargets() : string|array<string|int, string>
This method should return one or more of the constants Constraint::CLASS_CONSTRAINT and Constraint::PROPERTY_CONSTRAINT.
Return values
string|array<string|int, string> —One or more constant values
validatedBy()
Returns the name of the class that validates this constraint.
public
validatedBy() : string
By default, this is the fully qualified name of the constraint class suffixed with "Validator". You can override this method to change that behavior.
Return values
stringnormalizeOptions()
protected
normalizeOptions(mixed $options) : array<string|int, mixed>
Parameters
- $options : mixed