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

is.Latitude/Longitude #185

Open
kurennoy16 opened this issue Jul 6, 2023 · 0 comments
Open

is.Latitude/Longitude #185

kurennoy16 opened this issue Jul 6, 2023 · 0 comments

Comments

@kurennoy16
Copy link

I faced the issue with validating geo coordinates using is pkg.
Code example:

type GeoPosition struct {
	Latitude  float32
	Longitude float32
}

func (g *GeoPosition) Validate() error {
	return validation.ValidateStruct(g,
		validation.Field(&g.Latitude, validation.Required, is.Latitude),
		validation.Field(&g.Longitude, validation.Required, is.Longitude),
	)
}

It returns an error like that: GeoPosition: (Latitude: must be either a string or byte slice.)..
That confuses me a bit. I dug into the issues and found that is pkg only applicable to string/slice byte types.

So what's the way to address Latitude/Longitude validation for float types?
I see only one option - custom validation creation, but that's an inconvenient way to handle that. Any plans to use generics for that?

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

1 participant