Closed mithRabbit closed 3 months ago
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
-