Skip to content

Commit 79e5a7d

Browse files
author
jchadwick-buf
authored
Remove deprecated options (#297)
Removes deprecated fields in `validate.proto`, removes mention of them from relevant documentation, and replaces usages in the conformance suite with the proper up-to-date options. **This is a breaking change.** Runtime PRs: - Go: bufbuild/protovalidate-go#178 - C++: bufbuild/protovalidate-cc#69 - Python: bufbuild/protovalidate-python#246 - Java: bufbuild/protovalidate-java#235
1 parent 65f2484 commit 79e5a7d

31 files changed

+3225
-3293
lines changed

MODULE.bazel

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,5 @@ use_repo(go_deps, "com_github_bufbuild_protocompile", "com_github_spf13_pflag",
3434

3535
buf = use_extension("@rules_buf//buf:extensions.bzl", "buf")
3636
buf.toolchains(
37-
sha256 = "bb9d7b4a1fc9ddebc285faa09b9c3e4ce176b94585a1d7988371d73b208aa0f5",
38-
version = "v1.35.0",
37+
version = "v1.50.0",
3938
)

MODULE.bazel.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WORKSPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ load("@rules_buf//buf:repositories.bzl", "rules_buf_dependencies", "rules_buf_to
7070

7171
rules_buf_dependencies()
7272

73-
rules_buf_toolchains(version = "v1.35.0")
73+
rules_buf_toolchains(version = "v1.50.0")
7474

7575
load("@rules_buf//gazelle/buf:repositories.bzl", "gazelle_buf_dependencies")
7676

docs/standard-constraints.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,8 @@ proper validations for each field type:
9999
```protobuf
100100
message FieldConstraints {
101101
repeated Constraint cel = 23;
102-
bool skipped = 24;
103102
bool required = 25;
104-
bool ignore_empty = 26;
103+
Ignore ignore = 27;
105104
oneof type {
106105
// Scalar Field Types
107106
// ...
@@ -212,13 +211,13 @@ message Event {
212211

213212
### Other constraints
214213

215-
`FieldConstraints` contains other constraints that can be applied to fields
216-
including `skipped`, `required`, and `ignore_empty`.
214+
`FieldConstraints` contains other constraints that can be applied to fields,
215+
including `required` and `ignore`.
217216

218217
```protobuf
219218
message Event {
220219
int64 start_time = 1 [(buf.validate.field).required = true];
221-
int64 end_time = 2[(buf.validate.field).ignore_empty = true];
220+
int64 end_time = 2[(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED];
222221
}
223222
```
224223

examples/buf.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ deps:
44
- buf.build/bufbuild/protovalidate
55
lint:
66
use:
7-
- DEFAULT
7+
- STANDARD
88
except:
99
- DIRECTORY_SAME_PACKAGE
1010
- PACKAGE_DEFINED

examples/option_field_ignore_empty.proto

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ message SubmitFeedbackRequest {
2525
string feedback = 1;
2626
// email is the email.
2727
string email = 2 [
28-
// `ignore_empty` skips validation on a field if it's empty.
29-
// The email will be not validated if it's empty.
30-
(buf.validate.field).ignore_empty = true,
28+
// `IGNORE_IF_UNPOPULATED` skips validation on a field if it's unpopulated.
29+
// The email will be not validated if it's the empty string.
30+
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
3131
// `string.email` validates that a string field is a valid email.
3232
(buf.validate.field).string.email = true
3333
];

examples/option_number_allow_values.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ service CarService {
2323

2424
message SearchCarRequest {
2525
optional fixed32 number_of_seats = 1 [(buf.validate.field) = {
26-
// `ignore_empty` skips validation if the field isn't set.
27-
ignore_empty: true
26+
// `IGNORE_IF_UNPOPULATED` skips validation if the field isn't set.
27+
ignore: IGNORE_IF_UNPOPULATED
2828
fixed32: {
2929
// `in` requires that the value must be one of the specified values.
3030
// In this case, it validates that the number of seats is either 5 or 7.

examples/option_number_range.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ message CreateReviewRequest {
3737
message CreateReviewResponse {
3838
// aggregated_review is the aggregated review after this one in request is created.
3939
// This value is empty if there are less than a 100 reviews submitted.
40-
AggregatedReview aggregated_review = 1 [(buf.validate.field).ignore_empty = true];
40+
AggregatedReview aggregated_review = 1 [(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED];
4141
}
4242

4343
message AggregatedReview {

examples/option_string_match_pattern.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ message UserProfile {
2929
// must match it.
3030
pattern: "^(\\+\\d{1,2}\\s)?\\(?\\d{3}\\)?[\\s.-]\\d{3}[\\s.-]\\d{4}$"
3131
}
32-
ignore_empty: true
32+
ignore: IGNORE_IF_UNPOPULATED
3333
}];
3434
// `hostname` specifies that the field value must be a valid hostname as defined
3535
// by [RFC 1034](https://tools.ietf.org/html/rfc1034#section-3.5).
@@ -43,7 +43,7 @@ message UserProfile {
4343
// defined by [RFC 3986](https://tools.ietf.org/html/rfc3986#section-3).
4444
// (buf.validate.field).string.uri_ref = true,
4545
(buf.validate.field).string.uri = true,
46-
(buf.validate.field).ignore_empty = true
46+
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED
4747
];
4848
// `ip` specifies that a string field must be a valid ip address, in either v4 or v6.
4949
string last_login_at = 6 [(buf.validate.field).string.ip = true];

proto/protovalidate-testing/buf.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ breaking:
1212
- buf/validate/conformance
1313
lint:
1414
use:
15-
- DEFAULT
15+
- STANDARD
1616
except:
1717
- PROTOVALIDATE
1818
ignore_only:

0 commit comments

Comments
 (0)