|
|
@ -304,12 +304,48 @@ func isSSN(fl FieldLevel) bool { |
|
|
|
|
|
|
|
|
|
|
|
// IsLongitude is the validation function for validating if the field's value is a valid longitude coordinate.
|
|
|
|
// IsLongitude is the validation function for validating if the field's value is a valid longitude coordinate.
|
|
|
|
func isLongitude(fl FieldLevel) bool { |
|
|
|
func isLongitude(fl FieldLevel) bool { |
|
|
|
return longitudeRegex.MatchString(fmt.Sprint(fl.Field().Interface())) |
|
|
|
field := fl.Field() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var v string |
|
|
|
|
|
|
|
switch field.Kind() { |
|
|
|
|
|
|
|
case reflect.String: |
|
|
|
|
|
|
|
v = field.String() |
|
|
|
|
|
|
|
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: |
|
|
|
|
|
|
|
v = strconv.FormatInt(field.Int(), 10) |
|
|
|
|
|
|
|
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: |
|
|
|
|
|
|
|
v = strconv.FormatUint(field.Uint(), 10) |
|
|
|
|
|
|
|
case reflect.Float32: |
|
|
|
|
|
|
|
v = strconv.FormatFloat(field.Float(), 'f', -1, 32) |
|
|
|
|
|
|
|
case reflect.Float64: |
|
|
|
|
|
|
|
v = strconv.FormatFloat(field.Float(), 'f', -1, 64) |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
panic(fmt.Sprintf("Bad field type %T", field.Interface())) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return longitudeRegex.MatchString(v) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// IsLatitude is the validation function for validating if the field's value is a valid latitude coordinate.
|
|
|
|
// IsLatitude is the validation function for validating if the field's value is a valid latitude coordinate.
|
|
|
|
func isLatitude(fl FieldLevel) bool { |
|
|
|
func isLatitude(fl FieldLevel) bool { |
|
|
|
return latitudeRegex.MatchString(fmt.Sprint(fl.Field().Interface())) |
|
|
|
field := fl.Field() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var v string |
|
|
|
|
|
|
|
switch field.Kind() { |
|
|
|
|
|
|
|
case reflect.String: |
|
|
|
|
|
|
|
v = field.String() |
|
|
|
|
|
|
|
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: |
|
|
|
|
|
|
|
v = strconv.FormatInt(field.Int(), 10) |
|
|
|
|
|
|
|
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: |
|
|
|
|
|
|
|
v = strconv.FormatUint(field.Uint(), 10) |
|
|
|
|
|
|
|
case reflect.Float32: |
|
|
|
|
|
|
|
v = strconv.FormatFloat(field.Float(), 'f', -1, 32) |
|
|
|
|
|
|
|
case reflect.Float64: |
|
|
|
|
|
|
|
v = strconv.FormatFloat(field.Float(), 'f', -1, 64) |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
panic(fmt.Sprintf("Bad field type %T", field.Interface())) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return latitudeRegex.MatchString(v) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// IsDataURI is the validation function for validating if the field's value is a valid data URI.
|
|
|
|
// IsDataURI is the validation function for validating if the field's value is a valid data URI.
|
|
|
|