[Feature Request] - Document a CEL example for restricting string UUIDs to v4 or v7
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 50/100
- issue の種類
- ドキュメント
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- go
- 領域
- documentation, testing
調査の方向性
Start with the existing string uuid rule and the CEL extension mechanism it sits on, at the revision the issue cites (d06a71c9). Write a documented CEL predicate that checks the version nibble (4 or 7) and the RFC variant (8, 9, a, b), case-insensitively, and leaves shape checks to the generic uuid rule. Done means the conformance vectors in the issue (accept v4/v7, reject v1, wrong variant, Nil and Max) pass, and the docs say how empty values follow the ignore policy. Maintainers have not yet confirmed where the example should live.
索引モデルが issue の本文から書いたものです。
説明
Feature description:
I’d like to see a documented CEL example for schemas that need string UUIDs to be limited to versions 4 or 7.
The existing generic UUID validation should keep its current meaning. This request is only for a stricter, opt-in example built on top of the existing UUID format rule.
The example would combine:
- normal
UUIDformat validation; - a v4 or v7 version check;
- RFC variant validation.
I’d keep the initial example limited to canonical hyphenated UUID strings.
Problem it solves or use case:
The existing UUID rule validates UUID syntax, but it intentionally does not restrict the UUID version or variant.
That’s useful as a general-purpose rule, but some APIs want a narrower contract, for example:
- externally generated IDs must be
UUIDv4; - newer identifiers may be
UUIDv7; - other
UUIDversions should not be accepted; - values with the wrong RFC variant should also be rejected.
Today that requires users to work out the additional CEL expression themselves.
The existing UUID rule validates UUID syntax, but it intentionally does not restrict the UUID version or variant.
That’s useful as a general-purpose rule, but some APIs want a narrower contract, for example:
- externally generated IDs must be UUIDv4;
- newer identifiers may be
UUIDv7; - other UUID versions should not be accepted;
values with the wrong RFC variant should also be rejected.
Today that requires users to work out the additional CEL expression themselves.
A small documented example would show how to keep the generic UUID rule while layering a project-specific UUID policy on top of it, without suggesting that Protovalidate’s existing uuid behavior is incorrect.
Proposed implementation or solution:
I’d suggest documenting an example that uses the existing extension/CEL mechanism together with the normal string UUID rule.
The additional CEL predicate should accept:
- version nibble
4; - version nibble
7; - variant nibble
8,9,a, orb; - uppercase hexadecimal equivalents.
It should reject:
UUIDsusing other versions;- a v4/v7
UUIDwith the wrong variant; - Nil
UUID; - Max
UUID.
The generic UUID rule should still be responsible for validating the overall UUID shape, rather than duplicating all UUID parsing logic in the additional expression.
Existing ignore semantics should continue to apply. For example, empty values should behave according to whichever ignore policy is used in the surrounding field rule.
I would not change any core rule as part of this:
- no change to
uuid; - no change to
tuuid; - no change to bytes
UUIDrules; - no new core schema field.
If there is enough demand later, a reusable built-in version constraint could be discussed separately.
Contribution:
I’d be happy to help refine the CEL expression and the conformance cases for the documentation example.
I’d also be willing to help with the documentation/tests if this direction fits the project.
Examples or references:
A small set of useful conformance vectors would be:
Input - 00000000-0000-4000-8000-000000000000
Expected - Accept
Input - 00000000-0000-7000-8000-000000000000
Expected - Accept
Input - 00000000-0000-1000-8000-000000000000
Expected - Reject: version
Input - 00000000-0000-4000-c000-000000000000
Expected - Reject: variant
Input - 00000000-0000-0000-0000-000000000000
Expected - Reject: Nil UUID
Input - ffffffff-ffff-ffff-ffff-ffffffffffffReject:
Expected - Max UUID
It would also be useful to cover:
- uppercase valid input;
- malformed
UUIDlength/format; - empty values under the chosen ignore policy.
If the project demonstrates CEL portability across multiple language implementations, the same vectors could be used there as well.
Additional context:
This came from looking at the current UUID rule behavior around revision d06a71c9ba254a56c10a7085e1dd44d33cedeb56.
The existing behavior appears intentional: the generic string UUID rule validates UUID format without imposing a particular version or variant. I’m not proposing to change that contract.
The goal is just to give users a tested example for the common case where an API wants a stricter v4/v7 UUID policy while still relying on Protovalidate’s existing UUID validation.
- 主要言語
- Go
- スター
- 1.6k
- フォーク
- 68
- 平均マージ
- 4日 21時間
- マージ済み PR(30日)
- 4
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bufbuild/protovalidate のほかの issue
-
[BUG] Hostname rule rejects a 253-character name with a trailing dot, which the docs say is validオープン
難易度 4/5 3〜5日 初心者へのやさしさ 58/100
bufbuild/protovalidate#512 · コメント 2 件 ·
-
Feature
難易度 5/5 1週間以上 初心者へのやさしさ 45/100
bufbuild/protovalidate#490 · コメント 1 件 ·
-
Feature
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
bufbuild/protovalidate#486 · コメント 11 件 ·
-
Feature
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
bufbuild/protovalidate#485 ·
-
Feature
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
bufbuild/protovalidate#483 · リアクション 1 件 ·
bufbuild/protovalidate の issue をすべて見る
似ている issue
-
enhancement runtime:claude
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
FootprintAI/Containarium#3214 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
eugenioenko/ttt#1251 ·
メンテナーはふだん 1 日以内に返信
-
`compute.Service` client getters never cache their client対応中かも @jay23606 が今日担当しました。 オープンkind/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
kubernetes-sigs/cluster-api-provider-openstack#3441 ·
メンテナーはふだん 1 日以内に返信