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
// ID type. Must be ID_TYPE_PASSPORT or ID_TYPE_TAX_ID.
// IDType id_type = 1 [(google.api.field_behavior) = REQUIRED, (buf.validate.field).enum = {in: [1,2]}];
build the protobuf
run the validator
v, err := protovalidate.New()
if err != nil {
panic(err)
}
if err := v.Validate(req); err != nil {
panic(err)
}
Expected Behavior
id_type : value must be in list [ID_TYPE_PASSPORT , ID_TYPE_TAX_ID]
Unfortunately, CEL does not preserve details about the enum itself (like value names) and is only capable of preserving the integer values of the enum types. For all enum related rules you'll see error messages presenting the integer value as this is a limitation of CEL.
Description
enum validation message is not correct
Steps to Reproduce
write proto message
enum IDType {
ID_TYPE_UNSPECIFIED = 0;
ID_TYPE_PASSPORT = 1;
ID_TYPE_TAX_ID = 2;
}
// ID type. Must be
ID_TYPE_PASSPORT
orID_TYPE_TAX_ID
.// IDType id_type = 1 [(google.api.field_behavior) = REQUIRED, (buf.validate.field).enum = {in: [1,2]}];
build the protobuf
run the validator
v, err := protovalidate.New()
if err != nil {
panic(err)
}
if err := v.Validate(req); err != nil {
panic(err)
}
Expected Behavior
id_type : value must be in list [
ID_TYPE_PASSPORT
,ID_TYPE_TAX_ID
]Actual Behavior
ID_TYPE_PASSPORT
orID_TYPE_TAX_ID
Screenshots/Logs
Environment
Operating System: macos>
Version: sonoma Version 14.4.1 (23E224)
Compiler/Toolchain: <go 1.22.2>
// - protoc-gen-go-grpc v1.3.0
// - protoc v4.23.4
Protovalidate Version: v0.6.2
Possible Solution
Additional Context
The text was updated successfully, but these errors were encountered: