Do you have a plan to implement any protobuf message validation?
Or maybe you have any recommendations how to do the message validation in more generic, configurable way?
I don't plan to implement validation myself, but I consider adding support for one of the existing grpc/protobuf validation frameworks so you can just add the library.
Here is a PR for that: https://github.com/yidongnan/grpc-spring-boot-starter/pull/487/files
And a working library can be found here:
https://github.com/envoyproxy/protoc-gen-validate
Just add a ReflectiveValidatorIndex and @GrpcGlobalServerInterceptor ValidatingServerInterceptor bean to your config
Thank you, for the information!
Hello @ST-DDT,
i reviewed this PR https://github.com/yidongnan/grpc-spring-boot-starter/pull/487/files and found that is exactly what I'm looking for, since it will provide an option to create our custom validation logic using GrpcConstraintValidator.
I'm still novice in gRPC and trying to find the way how to validate for null values. For example we have a message:
message PersonProto {
google.protobuf.Int64Value id = 1;
google.protobuf.Int64Value userId = 2;
}
we don't want to use a primitive uint64 type since the default value would be 0 which is misleading and that's why we are using Int64Value. At the same time we want to have a null check validation logic on client and service side.
Correct my if i wrong, but the [protoc-gen-validate] library doesn't provide this validation option.
So, i think for now only one option would be to create a custom validator using the GrpcConstraintValidator.
Correct my if i wrong, but the
[protoc-gen-validate]library doesn't provide this validation option.
I think its called required.
https://github.com/envoyproxy/protoc-gen-validate#messages
PS: grpc Message = Java DTO/POJO