Skip to content

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

@wsb1994

Description

@wsb1994

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions