You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature description:
Thanks for this great idea and great library!
I would like to see the custom option (of host messages) to accessible by protovalidate / CEL.
so that the validation rule basically limit the value of "pos" to be one of "noun", "verb", etc. (as long as we supply alt_name for each enum value.
This particular case might be trickier (than what's required by this feature), it will have to somehow aggregate the alt_name from all enum values, and use that set as the target for "in" operation: you get the idea.
But in general, I want to access to the custom option as supplied by original protobuf authors, in protovalidate, or more generally in CEL.
Proposed implementation or solution:
I guess beside binding "this" into the evaluation context, you need to somehow make the custom options (of the host message) accessible from inside the evaluation context as well.
Contribution:
I don't have time to implement, but I'm happy to elaborate and help testing the feature.
The text was updated successfully, but these errors were encountered:
Hey @yangzh! Thanks for the thoughtful question! Out of the box, CEL does not have a lot of reflection support to get information off the types themselves. Enums especially are erased to just their int32 value. Protovalidate could potentially expose more reflection information in the CEL environment in the future, but for now we are keeping the rules scoped to the element (message or oneof or field) they're attached to.
Feature description:
Thanks for this great idea and great library!
I would like to see the custom option (of host messages) to accessible by protovalidate / CEL.
For example, if I have a .proto file:
extend google.protobuf.EnumValueOptions {
string alt_name = 10000;
}
enum PartOfSpeech {
UNKNOWN = 0;
NOUN = 1 [(alt_name) = "noun"];
VERB = 2 [(alt_name) = "verb"];
etc.
}
message Token {
string pos = 1 [(buf.protovalidate).string = {
in_enum_values: "alt_name" }];
}
so that the validation rule basically limit the value of "pos" to be one of "noun", "verb", etc. (as long as we supply alt_name for each enum value.
This particular case might be trickier (than what's required by this feature), it will have to somehow aggregate the alt_name from all enum values, and use that set as the target for "in" operation: you get the idea.
But in general, I want to access to the custom option as supplied by original protobuf authors, in protovalidate, or more generally in CEL.
Proposed implementation or solution:
I guess beside binding "this" into the evaluation context, you need to somehow make the custom options (of the host message) accessible from inside the evaluation context as well.
Contribution:
I don't have time to implement, but I'm happy to elaborate and help testing the feature.
The text was updated successfully, but these errors were encountered: