Skip to content

Commit

Permalink
Remove deprecated options
Browse files Browse the repository at this point in the history
  • Loading branch information
jchadwick-buf committed Jan 27, 2025
1 parent 24c9cf4 commit 7764aea
Show file tree
Hide file tree
Showing 29 changed files with 3,091 additions and 3,172 deletions.
9 changes: 4 additions & 5 deletions docs/standard-constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ proper validations for each field type:
```protobuf
message FieldConstraints {
repeated Constraint cel = 23;
bool skipped = 24;
bool required = 25;
bool ignore_empty = 26;
Ignore ignore = 27;
oneof type {
// Scalar Field Types
// ...
Expand Down Expand Up @@ -212,13 +211,13 @@ message Event {

### Other constraints

`FieldConstraints` contains other constraints that can be applied to fields
including `skipped`, `required`, and `ignore_empty`.
`FieldConstraints` contains other constraints that can be applied to fields,
including `required` and `ignore`.

```protobuf
message Event {
int64 start_time = 1 [(buf.validate.field).required = true];
int64 end_time = 2[(buf.validate.field).ignore_empty = true];
int64 end_time = 2[(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED];
}
```

Expand Down
2 changes: 1 addition & 1 deletion examples/buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ deps:
- buf.build/bufbuild/protovalidate
lint:
use:
- DEFAULT
- STANDARD
except:
- DIRECTORY_SAME_PACKAGE
- PACKAGE_DEFINED
Expand Down
2 changes: 1 addition & 1 deletion examples/option_field_ignore_empty.proto
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ message SubmitFeedbackRequest {
string email = 2 [
// `ignore_empty` skips validation on a field if it's empty.
// The email will be not validated if it's empty.
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
// `string.email` validates that a string field is a valid email.
(buf.validate.field).string.email = true
];
Expand Down
2 changes: 1 addition & 1 deletion examples/option_number_range.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ message CreateReviewRequest {
message CreateReviewResponse {
// aggregated_review is the aggregated review after this one in request is created.
// This value is empty if there are less than a 100 reviews submitted.
AggregatedReview aggregated_review = 1 [(buf.validate.field).ignore_empty = true];
AggregatedReview aggregated_review = 1 [(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED];
}

message AggregatedReview {
Expand Down
2 changes: 1 addition & 1 deletion examples/option_string_match_pattern.proto
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ message UserProfile {
// defined by [RFC 3986](https://tools.ietf.org/html/rfc3986#section-3).
// (buf.validate.field).string.uri_ref = true,
(buf.validate.field).string.uri = true,
(buf.validate.field).ignore_empty = true
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED
];
// `ip` specifies that a string field must be a valid ip address, in either v4 or v6.
string last_login_at = 6 [(buf.validate.field).string.ip = true];
Expand Down
2 changes: 1 addition & 1 deletion proto/protovalidate-testing/buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ breaking:
- buf/validate/conformance
lint:
use:
- DEFAULT
- STANDARD
except:
- PROTOVALIDATE
ignore_only:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ message BytesNotIPv6 {
message BytesIPv6Ignore {
bytes val = 1 [
(buf.validate.field).bytes.ipv6 = true,
(buf.validate.field).ignore_empty = true
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED
];
}
message BytesExample {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,29 @@ import "buf/validate/validate.proto";

message IgnoreEmptyProto2ScalarOptional {
optional int32 val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).int32.gt = 0
];
}

message IgnoreEmptyProto2ScalarOptionalWithDefault {
optional int32 val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).int32.gt = 0,
default = 42
];
}

message IgnoreEmptyProto2ScalarRequired {
required int32 val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).int32.gt = 0
];
}

message IgnoreEmptyProto2Message {
optional Msg val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).cel = {
id: "ignore_empty.proto2.message"
message: "foobar"
Expand All @@ -57,22 +57,22 @@ message IgnoreEmptyProto2Message {
message IgnoreEmptyProto2Oneof {
oneof o {
int32 val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).int32.gt = 0
];
}
}

message IgnoreEmptyProto2Repeated {
repeated int32 val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).repeated.min_items = 3
];
}

message IgnoreEmptyProto2Map {
map<int32, int32> val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).map.min_pairs = 3
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ import "buf/validate/validate.proto";

message IgnoreEmptyProto3Scalar {
int32 val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).int32.gt = 0
];
}

message IgnoreEmptyProto3OptionalScalar {
optional int32 val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).int32.gt = 0
];
}

message IgnoreEmptyProto3Message {
optional Msg val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).cel = {
id: "ignore_empty.proto3.message"
message: "foobar"
Expand All @@ -49,41 +49,41 @@ message IgnoreEmptyProto3Message {
message IgnoreEmptyProto3Oneof {
oneof o {
int32 val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).int32.gt = 0
];
}
}

message IgnoreEmptyProto3Repeated {
repeated int32 val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).repeated.min_items = 3
];
}

message IgnoreEmptyProto3Map {
map<int32, int32> val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).map.min_pairs = 3
];
}

message IgnoreEmptyRepeatedItems {
repeated int32 val = 1 [(buf.validate.field).repeated.items = {
ignore_empty: true
ignore: IGNORE_IF_UNPOPULATED,
int32: {gt: 0}
}];
}

message IgnoreEmptyMapPairs {
map<string, int32> val = 1 [
(buf.validate.field).map.keys = {
ignore_empty: true
ignore: IGNORE_IF_UNPOPULATED,
string: {min_len: 3}
},
(buf.validate.field).map.values = {
ignore_empty: true
ignore: IGNORE_IF_UNPOPULATED,
int32: {gt: 0}
}
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import "buf/validate/validate.proto";

message IgnoreEmptyEditionsScalarExplicitPresence {
int32 val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).int32.gt = 0
];
}

message IgnoreEmptyEditionsScalarExplicitPresenceWithDefault {
int32 val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).int32.gt = 0,
default = 42
];
Expand All @@ -36,31 +36,31 @@ message IgnoreEmptyEditionsScalarExplicitPresenceWithDefault {
message IgnoreEmptyEditionsScalarImplicitPresence {
int32 val = 1 [
features.field_presence = IMPLICIT,
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).int32.gt = 0
];
}

message IgnoreEmptyEditionsScalarLegacyRequired {
int32 val = 1 [
features.field_presence = LEGACY_REQUIRED,
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).int32.gt = 0
];
}

message IgnoreEmptyEditionsScalarLegacyRequiredWithDefault {
int32 val = 1 [
features.field_presence = LEGACY_REQUIRED,
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).int32.gt = 0,
default = 42
];
}

message IgnoreEmptyEditionsMessageExplicitPresence {
Msg val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).cel = {
id: "ignore_empty.editions.message"
message: "foobar"
Expand All @@ -75,7 +75,7 @@ message IgnoreEmptyEditionsMessageExplicitPresence {
message IgnoreEmptyEditionsMessageExplicitPresenceDelimited {
Msg val = 1 [
features.message_encoding = DELIMITED,
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).cel = {
id: "ignore_empty.editions.message"
message: "foobar"
Expand All @@ -90,7 +90,7 @@ message IgnoreEmptyEditionsMessageExplicitPresenceDelimited {
message IgnoreEmptyEditionsMessageLegacyRequired {
Msg val = 1 [
features.field_presence = LEGACY_REQUIRED,
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).cel = {
id: "ignore_empty.editions.message"
message: "foobar"
Expand All @@ -106,7 +106,7 @@ message IgnoreEmptyEditionsMessageLegacyRequiredDelimited {
Msg val = 1 [
features.message_encoding = DELIMITED,
features.field_presence = LEGACY_REQUIRED,
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).cel = {
id: "ignore_empty.editions.message"
message: "foobar"
Expand All @@ -121,30 +121,30 @@ message IgnoreEmptyEditionsMessageLegacyRequiredDelimited {
message IgnoreEmptyEditionsOneof {
oneof o {
int32 val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).int32.gt = 0
];
}
}

message IgnoreEmptyEditionsRepeated {
repeated int32 val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).repeated.min_items = 3
];
}

message IgnoreEmptyEditionsRepeatedExpanded {
repeated int32 val = 1 [
features.repeated_field_encoding = EXPANDED,
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).repeated.min_items = 3
];
}

message IgnoreEmptyEditionsMap {
map<int32, int32> val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).ignore = IGNORE_IF_UNPOPULATED,
(buf.validate.field).map.min_pairs = 3
];
}
Loading

0 comments on commit 7764aea

Please sign in to comment.