-
Notifications
You must be signed in to change notification settings - Fork 55
Description
Feature description:
Protovalidate supports arbitrary message level CEL rules that can validate fields based on other fields within the message scope.
However, the result validation will be tied to the field that references the message. What I'm suggesting is to support adding cel constraints on field level that allows referencing the parent message scope.
That way, when your validator interceptor collects google.rpc.BadRequest.FieldViolations, it will provide more detailed information on field paths.
Problem it solves or use case:
Fairly often used pattern for payloads is to have something like this:
(This is not to say it is the right approach, but often the case when a system is modeled as an RPC and protobuf is only used for payload schema, without gRPC best practices. I.e without oneof, but more like several optional/nullable fields that are required only for certain values as command)
Proposed implementation or solution:
Here's an improvised protobuf example, that would allow to have a violation that references a particular field path.
{ "command": "COMMAND_A", // Action payload corresponding to `COMMAND_A` "action_a": {}, "?action_b": null, "?action_c": null }