TheThingsIndustries / protoc-gen-fieldmask

Generate field mask utilities from proto files
Apache License 2.0
10 stars 3 forks source link

Generate validators per-fieldpath #21

Closed rvolosatovs closed 5 years ago

rvolosatovs commented 5 years ago

Summary:

The plugin should generate a func (*T) ValidateFields(...string) error method for each message. Required by https://github.com/TheThingsNetwork/lorawan-stack/issues/51

What is already there? What do you see now?

Only SetFields

What is missing? What do you want to see?

func (*T) ValidateFields(...string) error

How do you propose implementing this?

Follow the same structure as SetFields, instead of copying fields(terminal paths) - validate it according to the annotations. If no fields are specified to ValidateFields (i.e. it's called as ValidateFields()), all fields are validated. This lets ValidateFields have the same recursive structure as SetFields

The validation tags in protos could look the same as https://github.com/lyft/protoc-gen-validate In fact, we could reuse the tag definitions they already have.

What can you do yourself and what do you need help with?

I will add basic Validate method implementation and extend goType. @KrishnaIyer will then take over and add actual validator tags and their implementation as needed