TheThingsIndustries / protoc-gen-validate

protoc plugin to generate polyglot message validators
Apache License 2.0
1 stars 0 forks source link

Empty fields are not getting validated #4

Closed adriansmares closed 5 years ago

adriansmares commented 5 years ago

I've encountered an issue with validator generation in the case of oneof fields - the validator does not seem to check if the field is nil or not.

The proto I've tested this with is https://github.com/TheThingsNetwork/lorawan-stack/blob/895d4920ebd1a2dc5207f45b70c3b83eb896df7d/api/applicationserver_pubsub.proto#L48-L53 (I've seen that the same validation is used for ApplicationUp).

The resulting validator code does not check for nil fields - see https://github.com/TheThingsNetwork/lorawan-stack/blob/895d4920ebd1a2dc5207f45b70c3b83eb896df7d/pkg/ttnpb/applicationserver_pubsub.pb.validate.go#L322-L349 . If Provider is set to nil, the default path is never taken, since nats is added in case no sub fields are specified.

rvolosatovs commented 5 years ago