Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ message StringTUUID {
message StringNotTUUID {
string val = 1 [(buf.validate.field).string.tuuid = false];
}
message StringULID {
string val = 1 [(buf.validate.field).string.ulid = true];
}
message StringNotULID {
string val = 1 [(buf.validate.field).string.ulid = false];
}
message StringHttpHeaderName {
string val = 1 [(buf.validate.field).string.well_known_regex = KNOWN_REGEX_HTTP_HEADER_NAME];
}
Expand Down Expand Up @@ -223,6 +229,12 @@ message StringUUIDIgnore {
(buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE
];
}
message StringULIDIgnore {
string val = 1 [
(buf.validate.field).string = {ulid: true},
(buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE
];
}
message StringInOneof {
oneof foo {
string bar = 1 [(buf.validate.field).string = {
Expand Down
25 changes: 25 additions & 0 deletions proto/protovalidate/buf/validate/validate.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3731,6 +3731,31 @@ message StringRules {
}
];

// `ulid` specifies that the field value must be a valid ULID (Universally Unique
// Lexicographically Sortable Identifier) as defined by the [ULID specification](https://github.com/ulid/spec).
// ULID is a 26-character Base32-encoded string using Crockford's Base32 alphabet
// (0-9, A-Z excluding I, L, O, U). If the field value isn't a valid ULID, an error
// message will be generated.
//
// ```proto
// message MyString {
// // value must be a valid ULID
// string value = 1 [(buf.validate.field).string.ulid = true];
// }
// ```
bool ulid = 35 [
(predefined).cel = {
id: "string.ulid"
message: "value must be a valid ULID"
expression: "!rules.ulid || this == '' || this.matches('^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$')"
},
(predefined).cel = {
id: "string.ulid_empty"
message: "value is empty, which is not a valid ULID"
expression: "!rules.ulid || this != ''"
}
];

// `well_known_regex` specifies a common well-known pattern
// defined as a regex. If the field value doesn't match the well-known
// regex, an error message will be generated.
Expand Down
Loading