3 ms·
> Protobuf only allows you to add optional fields after the initial version, right? That’s not all. For example, you can also change fields from optional to re
by kccqzy 2mo ago
> Protobuf only allows you to add optional fields after the initial version, right?
That’s not all. For example, you can also change fields from optional to repeated or vice versa. For another example, you can also delete fields.
> Protobuf does not allow you to define contingent logic between fields.
You are just saying that protobuf is not a data validation library. That’s true; it only handles data serialization. You need to write validations yourself. And you will most likely need tests to test your validation code. But those are entirely tests within a single process; they are not tests involving a producer and a consumer of a protobuf message, which is the wrong kind of tests.
> For example if the charge type is "purchase" then price must be not null and > 0. That sort of thing.
That sort of thing sounds like you are not using `oneof` appropriately. The charge type shouldn’t be a field. It should be a submessage called Purchase.