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

Utilize validator package to provide systematic and expandable validation schema for the Go Etherium Project #27884

Closed
wsb1994 opened this issue Aug 8, 2023 · 1 comment

Comments

@wsb1994
Copy link

wsb1994 commented Aug 8, 2023

As it currently exists, a previous comment of mine discusses the addition of some simple validators. I created this issue as a potential easy pickup for beginners to assist in the go etherium project.

As it stands, go-validator and similar packages provide an easier way to handle validation steps in an easy to understand, expandable, and customizable way for any struct with custom fields and functions for validation. Including some built in validators.

This issue, is an open epic for adding some number of validators elsewhere in etherium using this idiomatic golang library support to provide this value add for the go-etherium project.

func (r *Resolver) Block(ctx context.Context, args struct {
	Number *Long
	Hash   *common
}) (*Block, error) {
	// Validate input arguments
	err := validateBlockArgs(args)
	if err != nil {
		return nil, err
	}

above is the validation function, using go-validate, which would then run the validation and return an error inline.

This is a much more go-thonic and sustainable way to do validation throughout etherium. This could compromise a substantial value add for other areas of the etherium project as well, providing more sustainable and expandable validation in many areas of the codebase.

Originally posted by @wsb1994 in #27876 (comment)

@karalabe
Copy link
Member

karalabe commented Aug 8, 2023

This is too much of a meta issue. If you wish to debate specific instances, you're more than welcome - and support them with code examples - but just opening an issue to "add validations everywhere" is not useful.

@karalabe karalabe closed this as completed Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants