uuid Module

The uuid module generates cryptographically strong, RFC-4122 compliant Universally Unique Identifiers (UUID Version 4).

Importing

djazair
use uuid

API Reference

FunctionDescription
uuid.v4()Generates a random UUID v4 string (e.g. "f47ac10b-58cc-4372-a567-0e02b2c3d479").
uuid.validate(uuidStr)Validates whether a string matches the standard 36-character UUID format.

Example Usage

djazair
use uuid

let newId = uuid.v4()
print("Generated UUID: ${newId}")

print("Is valid? ${uuid.validate(newId)}")   # => True
print("Is valid? ${uuid.validate("invalid")}") # => False