-
-
Notifications
You must be signed in to change notification settings - Fork 292
Closed
Description
Per https://github.com/envoyproxy/protoc-gen-validate#messages
If a field contains a message and the message has been generated with PGV, validation will be performed recursively. Message's not generated with PGV are skipped.
However ScalaPB's generated message validators assume all message types other than google.protobuf.* have validators and thus fails to compile when referencing message types without validators.
E.g. when using scalapb-validate-codegen and compiling this message
message Outer {
com.example.types.Foo foo = 1;
}
it will generate a validator like
object OuterValidator extends scalapb.validate.Validator[Outer] {
def validate(input: Outer): scalapb.validate.Result =
scalapb.validate.Result.optional(input.foo) { _value =>
com.example.types.FooValidator.validate(_value)
}
}
To avoid this problem, PGV's java implementation uses reflection to find message validators (caching result after first time) and uses a fallback always-valid validator for message types without validators:
Metadata
Metadata
Assignees
Labels
No labels