-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Allow latitude/longitude validation for numeric values #440
Conversation
c2f8e2c
to
52ea448
Compare
baked_in.go
Outdated
@@ -304,12 +304,12 @@ func isSSN(fl FieldLevel) bool { | |||
|
|||
// IsLongitude is the validation function for validating if the field's value is a valid longitude coordinate. | |||
func isLongitude(fl FieldLevel) bool { | |||
return longitudeRegex.MatchString(fl.Field().String()) | |||
return longitudeRegex.MatchString(fmt.Sprint(fl.Field().Interface())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like the change, it would be nice if you could add a type switch as it will allow the conversion from int to string to be much more efficient eg.
Line 193 in 52ea448
switch field.Kind() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a small benchmark to compare and you're right. Check the latest commits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool thanks, will try and merge in the next couple of days :)
…coords Allow latitude/longitude validation for numeric values
Make sure that you've checked the boxes below before you submit PR:
Change Details:
string
s.@go-playground/admins