Skip to content

Use getField CEL function #352

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

Merged
merged 4 commits into from
Apr 22, 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
68 changes: 34 additions & 34 deletions proto/protovalidate/buf/validate/validate.proto
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ message FloatRules {
// ```
optional float const = 1 [(predefined).cel = {
id: "float.const"
expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''"
expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''"
}];

oneof less_than {
Expand Down Expand Up @@ -592,7 +592,7 @@ message FloatRules {
// ```
repeated float in = 6 [(predefined).cel = {
id: "float.in"
expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''"
expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''"
}];

// `in` requires the field value to not be equal to any of the specified
Expand Down Expand Up @@ -661,7 +661,7 @@ message DoubleRules {
// ```
optional double const = 1 [(predefined).cel = {
id: "double.const"
expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''"
expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''"
}];
oneof less_than {
// `lt` requires the field value to be less than the specified value (field <
Expand Down Expand Up @@ -813,7 +813,7 @@ message DoubleRules {
// ```
repeated double in = 6 [(predefined).cel = {
id: "double.in"
expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''"
expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''"
}];

// `not_in` requires the field value to not be equal to any of the specified
Expand Down Expand Up @@ -882,7 +882,7 @@ message Int32Rules {
// ```
optional int32 const = 1 [(predefined).cel = {
id: "int32.const"
expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''"
expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''"
}];
oneof less_than {
// `lt` requires the field value to be less than the specified value (field
Expand Down Expand Up @@ -1035,7 +1035,7 @@ message Int32Rules {
// ```
repeated int32 in = 6 [(predefined).cel = {
id: "int32.in"
expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''"
expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''"
}];

// `not_in` requires the field value to not be equal to any of the specified
Expand Down Expand Up @@ -1097,7 +1097,7 @@ message Int64Rules {
// ```
optional int64 const = 1 [(predefined).cel = {
id: "int64.const"
expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''"
expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''"
}];
oneof less_than {
// `lt` requires the field value to be less than the specified value (field <
Expand Down Expand Up @@ -1250,7 +1250,7 @@ message Int64Rules {
// ```
repeated int64 in = 6 [(predefined).cel = {
id: "int64.in"
expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''"
expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''"
}];

// `not_in` requires the field value to not be equal to any of the specified
Expand Down Expand Up @@ -1312,7 +1312,7 @@ message UInt32Rules {
// ```
optional uint32 const = 1 [(predefined).cel = {
id: "uint32.const"
expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''"
expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''"
}];
oneof less_than {
// `lt` requires the field value to be less than the specified value (field <
Expand Down Expand Up @@ -1465,7 +1465,7 @@ message UInt32Rules {
// ```
repeated uint32 in = 6 [(predefined).cel = {
id: "uint32.in"
expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''"
expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''"
}];

// `not_in` requires the field value to not be equal to any of the specified
Expand Down Expand Up @@ -1527,7 +1527,7 @@ message UInt64Rules {
// ```
optional uint64 const = 1 [(predefined).cel = {
id: "uint64.const"
expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''"
expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''"
}];
oneof less_than {
// `lt` requires the field value to be less than the specified value (field <
Expand Down Expand Up @@ -1679,7 +1679,7 @@ message UInt64Rules {
// ```
repeated uint64 in = 6 [(predefined).cel = {
id: "uint64.in"
expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''"
expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''"
}];

// `not_in` requires the field value to not be equal to any of the specified
Expand Down Expand Up @@ -1740,7 +1740,7 @@ message SInt32Rules {
// ```
optional sint32 const = 1 [(predefined).cel = {
id: "sint32.const"
expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''"
expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''"
}];
oneof less_than {
// `lt` requires the field value to be less than the specified value (field
Expand Down Expand Up @@ -1893,7 +1893,7 @@ message SInt32Rules {
// ```
repeated sint32 in = 6 [(predefined).cel = {
id: "sint32.in"
expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''"
expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''"
}];

// `not_in` requires the field value to not be equal to any of the specified
Expand Down Expand Up @@ -1954,7 +1954,7 @@ message SInt64Rules {
// ```
optional sint64 const = 1 [(predefined).cel = {
id: "sint64.const"
expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''"
expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''"
}];
oneof less_than {
// `lt` requires the field value to be less than the specified value (field
Expand Down Expand Up @@ -2107,7 +2107,7 @@ message SInt64Rules {
// ```
repeated sint64 in = 6 [(predefined).cel = {
id: "sint64.in"
expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''"
expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''"
}];

// `not_in` requires the field value to not be equal to any of the specified
Expand Down Expand Up @@ -2168,7 +2168,7 @@ message Fixed32Rules {
// ```
optional fixed32 const = 1 [(predefined).cel = {
id: "fixed32.const"
expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''"
expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''"
}];
oneof less_than {
// `lt` requires the field value to be less than the specified value (field <
Expand Down Expand Up @@ -2321,7 +2321,7 @@ message Fixed32Rules {
// ```
repeated fixed32 in = 6 [(predefined).cel = {
id: "fixed32.in"
expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''"
expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''"
}];

// `not_in` requires the field value to not be equal to any of the specified
Expand Down Expand Up @@ -2382,7 +2382,7 @@ message Fixed64Rules {
// ```
optional fixed64 const = 1 [(predefined).cel = {
id: "fixed64.const"
expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''"
expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''"
}];
oneof less_than {
// `lt` requires the field value to be less than the specified value (field <
Expand Down Expand Up @@ -2535,7 +2535,7 @@ message Fixed64Rules {
// ```
repeated fixed64 in = 6 [(predefined).cel = {
id: "fixed64.in"
expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''"
expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''"
}];

// `not_in` requires the field value to not be equal to any of the specified
Expand Down Expand Up @@ -2596,7 +2596,7 @@ message SFixed32Rules {
// ```
optional sfixed32 const = 1 [(predefined).cel = {
id: "sfixed32.const"
expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''"
expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''"
}];
oneof less_than {
// `lt` requires the field value to be less than the specified value (field <
Expand Down Expand Up @@ -2749,7 +2749,7 @@ message SFixed32Rules {
// ```
repeated sfixed32 in = 6 [(predefined).cel = {
id: "sfixed32.in"
expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''"
expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''"
}];

// `not_in` requires the field value to not be equal to any of the specified
Expand Down Expand Up @@ -2810,7 +2810,7 @@ message SFixed64Rules {
// ```
optional sfixed64 const = 1 [(predefined).cel = {
id: "sfixed64.const"
expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''"
expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''"
}];
oneof less_than {
// `lt` requires the field value to be less than the specified value (field <
Expand Down Expand Up @@ -2963,7 +2963,7 @@ message SFixed64Rules {
// ```
repeated sfixed64 in = 6 [(predefined).cel = {
id: "sfixed64.in"
expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''"
expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''"
}];

// `not_in` requires the field value to not be equal to any of the specified
Expand Down Expand Up @@ -3025,7 +3025,7 @@ message BoolRules {
// ```
optional bool const = 1 [(predefined).cel = {
id: "bool.const"
expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''"
expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''"
}];

// `example` specifies values that the field may have. These values SHOULD
Expand Down Expand Up @@ -3072,7 +3072,7 @@ message StringRules {
// ```
optional string const = 1 [(predefined).cel = {
id: "string.const"
expression: "this != rules.const ? 'value must equal `%s`'.format([rules.const]) : ''"
expression: "this != getField(rules, 'const') ? 'value must equal `%s`'.format([getField(rules, 'const')]) : ''"
}];

// `len` dictates that the field value must have the specified
Expand Down Expand Up @@ -3258,7 +3258,7 @@ message StringRules {
// ```
repeated string in = 10 [(predefined).cel = {
id: "string.in"
expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''"
expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''"
}];

// `not_in` specifies that the field value cannot be equal to any
Expand Down Expand Up @@ -3833,7 +3833,7 @@ message BytesRules {
// ```
optional bytes const = 1 [(predefined).cel = {
id: "bytes.const"
expression: "this != rules.const ? 'value must be %x'.format([rules.const]) : ''"
expression: "this != getField(rules, 'const') ? 'value must be %x'.format([getField(rules, 'const')]) : ''"
}];

// `len` requires the field value to have the specified length in bytes.
Expand Down Expand Up @@ -3954,7 +3954,7 @@ message BytesRules {
// ```
repeated bytes in = 8 [(predefined).cel = {
id: "bytes.in"
expression: "dyn(rules)['in'].size() > 0 && !(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''"
expression: "getField(rules, 'in').size() > 0 && !(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''"
}];

// `not_in` requires the field value to be not equal to any of the specified
Expand Down Expand Up @@ -4091,7 +4091,7 @@ message EnumRules {
// ```
optional int32 const = 1 [(predefined).cel = {
id: "enum.const"
expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''"
expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''"
}];

// `defined_only` requires the field value to be one of the defined values for
Expand Down Expand Up @@ -4129,7 +4129,7 @@ message EnumRules {
// ```
repeated int32 in = 3 [(predefined).cel = {
id: "enum.in"
expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''"
expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''"
}];

// `not_in` requires the field value to be not equal to any of the
Expand Down Expand Up @@ -4381,7 +4381,7 @@ message DurationRules {
// ```
optional google.protobuf.Duration const = 2 [(predefined).cel = {
id: "duration.const"
expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''"
expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''"
}];
oneof less_than {
// `lt` stipulates that the field must be less than the specified value of the `google.protobuf.Duration` type,
Expand Down Expand Up @@ -4534,7 +4534,7 @@ message DurationRules {
// ```
repeated google.protobuf.Duration in = 7 [(predefined).cel = {
id: "duration.in"
expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''"
expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''"
}];

// `not_in` denotes that the field must not be equal to
Expand Down Expand Up @@ -4595,7 +4595,7 @@ message TimestampRules {
// ```
optional google.protobuf.Timestamp const = 2 [(predefined).cel = {
id: "timestamp.const"
expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''"
expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''"
}];
oneof less_than {
// requires the duration field value to be less than the specified value (field < value). If the field value doesn't meet the required conditions, an error message is generated.
Expand Down
Loading
Loading