Skip to content

improve error message for filter pass-by-value#166

Merged
inhere merged 2 commits intogookit:masterfrom
OscarVanL:chore/improve-error-message
Aug 27, 2022
Merged

improve error message for filter pass-by-value#166
inhere merged 2 commits intogookit:masterfrom
OscarVanL:chore/improve-error-message

Conversation

@OscarVanL
Copy link
Copy Markdown
Contributor

@OscarVanL OscarVanL commented Aug 26, 2022

I was trying out the filter feature today on a struct, but made a mistake and did not pass the struct by reference/pointer:

type Foo struct {
	A string `filter:"trim"`
}

func main() {
	foo := Foo{A: "    test     "}

	v := validate.Struct(foo)
	if !v.Validate() {
		fmt.Println(v.Errors.String())
	}
}

It took me a little while to figure out the problem because the error message was not very clear:

_filter:
 _filter: set value failure

This MR improves the error message to be more informative. Hopefully it helps others debug easier :)

@coveralls
Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 2936605061

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 96.17%

Totals Coverage Status
Change from base Build 2928020510: 0.0%
Covered Lines: 2787
Relevant Lines: 2898

💛 - Coveralls

@inhere inhere self-assigned this Aug 27, 2022
@inhere inhere added the enhancement New feature or request label Aug 27, 2022
@inhere inhere merged commit 5cac769 into gookit:master Aug 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants