public function Uuid::isValid

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

Plugins should not implement validation, since UUIDs should be in a consistent format across all plugins.

Parameters

string $uuid: The string to test.

Return value

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

File

drupal/core/lib/Drupal/Component/Uuid/Uuid.php, line 54
Definition of Drupal\Component\Uuid\Uuid.

Class

Uuid
Factory class for UUIDs.

Namespace

Drupal\Component\Uuid

Code

public function isValid($uuid) {
  return preg_match("/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}\$/", $uuid);
}