[Feature Request] - Document a CEL example for restricting string UUIDs to v4 or v7
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 50/100
- Tipo di issue
- Documentazione
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- go
- Ambito
- documentation, testing
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Go
- Stelle
- 1.6k
- Fork
- 68
- Merge medio
- 1g 10h
- PR unite (30g)
- 4
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di bufbuild/protovalidate
-
[BUG] Hostname rule rejects a 253-character name with a trailing dot, which the docs say is validAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 58/100
bufbuild/protovalidate#512 · 2 commenti ·
-
Feature
Difficoltà 5/5 Più di una settimana Idoneità per principianti 45/100
bufbuild/protovalidate#490 · 1 commento ·
-
Feature
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
bufbuild/protovalidate#486 · 11 commenti ·
-
Feature
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
bufbuild/protovalidate#485 ·
-
Feature
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
bufbuild/protovalidate#483 · 1 reazione ·
Tutte le issue di bufbuild/protovalidate
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 60/100
-
✨ Propose the missing gate after three same-class findings instead of filing a fourthForse già presa @hivecommons-hive l’ha presa oggi. Apertaenhancement help wanted hive/claimed-by-scanner stage/040-covered-by-pr
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
hivecommons/hive#13428 · 3 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
🕷️ bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
sysadminsmedia/homebox#1805 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100