Skip to content

isUUID

Checks if a string is in UUID (Universally Unique Identifier) format.

Syntax

typescript
isUUID(value: string): boolean

Parameters

NameTypeDescription
valuestringThe string to be checked

Returns

TypeDescription
booleanReturns true if the string is a valid UUID, otherwise false

Example

typescript
isUUID("123e4567-e89b-12d3-a456-426614174000"); // true
isUUID("not-a-uuid"); // false
isUUID(12345 as any); // throws TypeError

Notes

  • Throws a TypeError if the value is not a string.
  • The pattern accepts UUIDs version 1 to 5.

References

Released under the MIT License.