Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate validators per-fieldpath #21

Closed
rvolosatovs opened this issue Feb 13, 2019 · 0 comments
Closed

Generate validators per-fieldpath #21

rvolosatovs opened this issue Feb 13, 2019 · 0 comments
Assignees

Comments

@rvolosatovs
Copy link
Contributor

rvolosatovs commented Feb 13, 2019

Summary:

The plugin should generate a func (*T) ValidateFields(...string) error method for each message.
Required by TheThingsNetwork/lorawan-stack#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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants