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

🍀 Proposal: Use Validator for Config Validation #558

Closed
IronCore864 opened this issue May 20, 2022 · 4 comments · Fixed by #693
Closed

🍀 Proposal: Use Validator for Config Validation #558

IronCore864 opened this issue May 20, 2022 · 4 comments · Fixed by #693
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@IronCore864
Copy link
Member

IronCore864 commented May 20, 2022

What would you like to add? Why is this needed?

Background

Our community member @iyear introduced https://github.com/go-playground/validator into the project in this issue #511 (solved by this PR #533). This has greatly improved our plugin options validation.

However, the configloader module still uses manual validation: https://github.com/devstream-io/devstream/blob/main/internal/pkg/configloader/validation.go

Improvement

We can update the configloader's validation method to use the same validator mechanism.

It's worth noting that the logic here https://github.com/devstream-io/devstream/blob/main/internal/pkg/configloader/validation.go#L93 is a little complicated; we can implement it by something like this https://github.com/iyear/devstream/blob/9ec0591cc9a3b609b0d302d16cd6246c6119c606/internal/pkg/plugin/common/reposcaffolding/options.go#L11.

@IronCore864 IronCore864 added the good first issue Good for newcomers label May 20, 2022
@iyear
Copy link
Member

iyear commented May 20, 2022

If you are not familiar with this library,you may need to use these tags: https://github.com/go-playground/validator#other

And usages: https://github.com/go-playground/validator/blob/master/validator_test.go

@daniel-hutao
Copy link
Member

@iyear Thank you for your helpful information! You must be the next community member this month!

@daniel-hutao daniel-hutao added the enhancement New feature or request label May 20, 2022
@daniel-hutao
Copy link
Member

configloader has been refactored, as can be seen in #655. So some of the links above are no longer valid, but don't worry, the configloader is now much more readable and you can easily find where the validation logic is in this package. Please don't worry, feel free to leave a comment and let us know if you encounter any problems.

@mangoGoForward
Copy link
Contributor

[WeOpen Star]I would like to help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants