Expand description
First-class ID type generation and validation.
Supports: UUID v4, UUID v7, ULID, CUID2, NanoID.
All IDs are represented as strings for JSON compatibility. UUID v7 and ULID are time-sortable (lexicographic order = chronological order).
Functionsยง
- cuid2
- Generate a CUID2 (Collision-resistant Unique Identifier v2).
- cuid2_
with_ length - Generate a CUID2 with custom length (min 4, max 64).
- detect_
id_ type - Detect the type of a string ID.
- generate_
by_ type - Generate an ID by type name.
- is_
cuid2 - Validate whether a string looks like a CUID2 (starts with letter, alphanumeric).
- is_
nanoid - Validate whether a string looks like a NanoID (URL-safe characters, reasonable length).
- is_ulid
- Validate whether a string is a valid ULID.
- is_uuid
- Validate whether a string is a valid UUID (any version).
- nanoid
- Generate a NanoID (URL-friendly unique string identifier).
- nanoid_
with_ length - Generate a NanoID with custom length.
- ulid
- Generate a ULID (Universally Unique Lexicographically Sortable Identifier).
- ulid_
timestamp_ ms - Extract the millisecond timestamp from a ULID.
- uuid_v4
- Generate a random UUID v4 (128-bit, not time-sortable).
- uuid_v7
- Generate a time-sorted UUID v7 (128-bit, time-sortable).
- uuid_
version - Extract the version from a UUID string (1-7, or 0 if invalid).