Skip to content

Commit

Permalink
Add tuuid (#189)
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Roche <[email protected]>
  • Loading branch information
bufdev and rodaine authored Apr 1, 2024
1 parent b13e5a7 commit 3e01074
Show file tree
Hide file tree
Showing 3 changed files with 843 additions and 775 deletions.
2 changes: 2 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ github.com/golang/protobuf v1.5.0 h1:LUVKkCeviFUMKqHa4tXIIij/lbhnMbP7Fn5wKdKkRh4
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
golang.org/x/mod v0.6.0 h1:b9gGHsz9/HhJ3HF5DHQytPpuwocVTChQJK3AvoLRD5I=
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE=
Expand Down
24 changes: 24 additions & 0 deletions proto/protovalidate/buf/validate/validate.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3035,6 +3035,30 @@ message StringRules {
}
];

// `tuuid` (trimmed UUID) specifies that the field value must be a valid UUID as
// defined by [RFC 4122](https://tools.ietf.org/html/rfc4122#section-4.1.2) with all dashes
// omitted. If the field value isn't a valid UUID without dashes, an error message
// will be generated.
//
// ```proto
// message MyString {
// // value must be a valid trimmed UUID
// string value = 1 [(buf.validate.field).string.tuuid = true];
// }
// ```
bool tuuid = 33 [
(priv.field).cel = {
id: "string.tuuid",
message: "value must be a valid trimmed UUID",
expression: "this == '' || this.matches('^[0-9a-fA-F]{32}$')",
},
(priv.field).cel = {
id: "string.tuuid_empty",
message: "value is empty, which is not a valid trimmed UUID",
expression: "this != ''",
}
];

// `ip_with_prefixlen` specifies that the field value must be a valid IP (v4 or v6)
// address with prefix length. If the field value isn't a valid IP with prefix
// length, an error message will be generated.
Expand Down
Loading

0 comments on commit 3e01074

Please sign in to comment.