You are here

public static function Uuid::isValid in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Component/Uuid/Uuid.php \Drupal\Component\Uuid\Uuid::isValid()
  2. 10 core/lib/Drupal/Component/Uuid/Uuid.php \Drupal\Component\Uuid\Uuid::isValid()

Checks whether a string appears to be in the format of a UUID.

Implementations should not implement validation, since UUIDs should be in a consistent format across all implementations.

Parameters

string $uuid: The string to test.

Return value

bool TRUE if the string is well formed, FALSE otherwise.

7 calls to Uuid::isValid()
ConfigEntityTest::testCRUD in core/modules/config/tests/src/Functional/ConfigEntityTest.php
Tests CRUD operations.
ConfigInstallProfileOverrideTest::testInstallProfileConfigOverwrite in core/modules/config/tests/src/Functional/ConfigInstallProfileOverrideTest.php
Tests install profile config changes.
EntityFieldDefaultValueTest::assertDefaultValues in core/tests/Drupal/KernelTests/Core/Entity/EntityFieldDefaultValueTest.php
Executes a test set for a defined entity type.
JsonApiDocumentTopLevelNormalizer::validateRequestBody in core/modules/jsonapi/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php
Performs minimal validation of the document.
UuidItemTest::testSampleValue in core/modules/field/tests/src/Kernel/String/UuidItemTest.php
Tests 'uuid' random values.

... See full list

File

core/lib/Drupal/Component/Uuid/Uuid.php, line 27

Class

Uuid
UUID Helper methods.

Namespace

Drupal\Component\Uuid

Code

public static function isValid($uuid) {
  return (bool) preg_match('/^' . self::VALID_PATTERN . '$/', $uuid);
}