Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify rule string.uri_ref #305

Merged
merged 3 commits into from
Feb 4, 2025
Merged
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
22 changes: 14 additions & 8 deletions proto/protovalidate/buf/validate/validate.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3392,9 +3392,10 @@ message StringRules {
}
];

// `uri` specifies that the field value must be a valid,
// absolute URI as defined by [RFC 3986](https://tools.ietf.org/html/rfc3986#section-3). If the field value isn't a valid,
// absolute URI, an error message will be generated.
// `uri` specifies that the field value must be a valid URI as defined by
// [RFC 3986](https://tools.ietf.org/html/rfc3986#section-3).
//
// If the field value isn't a valid URI, an error message will be generated.
//
// ```proto
// message MyString {
Expand All @@ -3415,19 +3416,24 @@ message StringRules {
}
];

// `uri_ref` specifies that the field value must be a valid URI
// as defined by [RFC 3986](https://tools.ietf.org/html/rfc3986#section-3) and may be either relative or absolute. If the
// field value isn't a valid URI, an error message will be generated.
// `uri_ref` specifies that the field value must be a valid URI Reference as
// defined by [RFC 3986](https://tools.ietf.org/html/rfc3986#section-4.1).
//
// A URI Reference is either a [URI](https://tools.ietf.org/html/rfc3986#section-3),
// or a [Relative Reference](https://tools.ietf.org/html/rfc3986#section-4.2).
//
// If the field value isn't a valid URI Reference, an error message will be
// generated.
//
// ```proto
// message MyString {
// // value must be a valid URI
// // value must be a valid URI Reference
// string value = 1 [(buf.validate.field).string.uri_ref = true];
// }
// ```
bool uri_ref = 18 [(predefined).cel = {
id: "string.uri_ref"
message: "value must be a valid URI"
message: "value must be a valid URI Reference"
expression: "!rules.uri_ref || this.isUriRef()"
}];

Expand Down
Loading