Skip to content

Add UUID v7 support (and v6/v8) - #367

Merged
yezz123 merged 2 commits into
pydantic:mainfrom
sshaheerkhann:feat/uuid7-support
Feb 18, 2026
Merged

yezz123 merged 2 commits into
pydantic:mainfrom
sshaheerkhann:feat/uuid7-support

Conversation

@sshaheerkhann

Copy link
Copy Markdown
Contributor

Closes #204

Summary

Adds UUID version 6, 7, and 8 type support to pydantic-extra-types.

What's included

  • UUID6, UUID7, UUID8 — Annotated uuid.UUID types that validate the UUID version
  • uuid7() — Generation function using uuid.uuid7() on Python 3.14+ and uuid-utils on older versions
  • uuid7_to_datetime() — Extracts the embedded UTC timestamp from a UUID v7
  • Optional uuid-utils dependency for Python < 3.14
  • 23 new tests covering validation, serialization, generation, and timestamp extraction

Usage

from pydantic import BaseModel
from pydantic_extra_types.uuid_types import UUID7, uuid7, uuid7_to_datetime

class Document(BaseModel):
id: UUID7

doc = Document(id='018f0e8c-7a6a-7b1c-a3e4-fdf3e0ef7a4a')
new_id = uuid7()
dt = uuid7_to_datetime(doc.id)

@yezz123
yezz123 merged commit b999077 into pydantic:main Feb 18, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UUID v7 Support

2 participants