function Assert::uuid
@psalm-pure
Parameters
string $value:
string $message:
Throws
File
-
vendor/
webmozart/ assert/ src/ Assert.php, line 1909
Class
- Assert
- Efficient assertions to validate the input/output of your methods.
Namespace
Webmozart\AssertCode
public static function uuid($value, $message = '') {
$value = \str_replace(array(
'urn:',
'uuid:',
'{',
'}',
), '', $value);
// The nil UUID is special form of UUID that is specified to have all
// 128 bits set to zero.
if ('00000000-0000-0000-0000-000000000000' === $value) {
return;
}
if (!\preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/', $value)) {
static::reportInvalidArgument(\sprintf($message ?: 'Value %s is not a valid UUID.', static::valueToString($value)));
}
}