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

Uninformative message when validating a struct field via Var() #995

Closed
2 tasks done
Antonboom opened this issue Aug 25, 2022 · 2 comments
Closed
2 tasks done

Uninformative message when validating a struct field via Var() #995

Antonboom opened this issue Aug 25, 2022 · 2 comments

Comments

@Antonboom
Copy link

  • I have looked at the documentation here first?
  • I have looked at the examples provided that may showcase my question here?

Package version eg. v9, v10:

v10

Code sample, to showcase or reproduce:

package main

import (
	"fmt"
	"time"

	"github.com/go-playground/validator/v10"
)

var v = validator.New()

type Options struct {
	pingPeriod time.Duration
}

func main() {
	opts := Options{pingPeriod: 10 * time.Minute}

	err := v.Var(opts.pingPeriod, "min=1s,max=1m")
	fmt.Println(err)
	// Key: '' Error:Field validation for '' failed on the 'max' tag
	//      ^^^                           ^^^
}
@Antonboom
Copy link
Author

I think it is related to #417

@zemzale
Copy link
Member

zemzale commented Oct 5, 2022

@Antonboom Indeed the unexported field is the issue here. I will close this in favor of that issue.

@zemzale zemzale closed this as completed Oct 5, 2022
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

2 participants