Skip to content

Add uuid7 validation tag - #1614

Open
ChrisJr404 wants to merge 1 commit into
go-playground:masterfrom
ChrisJr404:feat/uuid7-validator
Open

Add uuid7 validation tag#1614
ChrisJr404 wants to merge 1 commit into
go-playground:masterfrom
ChrisJr404:feat/uuid7-validator

Conversation

@ChrisJr404

Copy link
Copy Markdown

What type of PR is this?

  • feature

What this PR does / why we need it:

Adds a built-in uuid7 validation tag for version 7 UUIDs (RFC 9562).

The library already validates UUID versions 3, 4 and 5, but there's no tag
for v7. UUIDv7 has become common as a time-ordered, index-friendly primary
key, so it's a natural addition to the existing set.

Changes, following the exact shape of the existing uuid5 support:

  • regexes.go: add uUID7RegexString / uUID7Regex. Same pattern as v4/v5
    with the version nibble pinned to 7 and the RFC 4122/9562 variant nibble
    [89ab].
  • baked_in.go: add isUUID7 and register the uuid7 tag.
  • doc.go and README.md: document the new tag.

Like uuid4/uuid5, uuid7 accepts lowercase hex only. I left a
case-insensitive uuid7_rfc4122-style variant out of this PR to keep it
focused and because the right name for it (given v7 is defined in RFC 9562,
not 4122) is a call I'd rather leave to you — happy to add it in a follow-up.

Which issue(s) this PR fixes:

Fixes #1595

Testing

Added TestUUID7Validation mirroring the existing UUID tests: empty input,
garbage prefix, wrong-version UUIDs (v3/v4), an invalid variant nibble, an
uppercase value (rejected), and two valid v7 values. go test ./... passes;
go vet is clean.

Release Notes

Add `uuid7` validation tag for RFC 9562 version 7 UUIDs.

Adds a built-in uuid7 tag validating version 7 UUIDs (RFC 9562),
mirroring the existing uuid3/uuid4/uuid5 validators. Includes regex,
validation function, registration, docs (doc.go + README) and tests.

Fixes go-playground#1595
@ChrisJr404
ChrisJr404 requested a review from a team as a code owner August 18, 2026 15:52
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 的验证

1 participant