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

Fix longlat validators #108

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from
10 changes: 6 additions & 4 deletions helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,12 @@ var (
"00:02:x2:34:72:a5": false,
}
_numericStringList = inputs{"12": true, "09": true, "878": true, "100": true, "a": false, "xyz": false, "1000000000000": true}
_latList = inputs{"30.297018": true, "40.044438": true, "a": false, "xyz": false}
_lonList = inputs{"-78.486328": true, "-104.0625": true, "a": false, "xyz": false}
_ipList = inputs{"10.255.255.255": true, "172.31.255.255": true, "192.168.255.255": true, "a92.168.255.255": false, "172.31.255.25b": false}
_ipV6List = inputs{
_latList = inputs{"30.297018": true, "40.044438": true, "-90": true, "+90.0": true,
"51.50975743908446": true, "123.323223": false, "a": false, "xyz": false}
_lonList = inputs{"-78.486328": true, "-104.0625": true, "-0.09299784755596675": true, "-180.000": true, "+180":true,
"179.3": true, "180.00001": false, "-190": false, "a": false, "xyz": false}
_ipList = inputs{"10.255.255.255": true, "172.31.255.255": true, "192.168.255.255": true, "a92.168.255.255": false, "172.31.255.25b": false}
_ipV6List = inputs{
"1200:0000:AB00:1234:0000:2552:7777:1313": true,
"21DA:D3:0:2F3B:2AA:FF:FE28:9C5A": true,
"10.255.255.255": false,
Expand Down
4 changes: 2 additions & 2 deletions regex_patterns.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ const (
// IPV6 represents regular expression for ip address version 6
IPV6 string = `^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*(\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))?$`
// Latitude represents latitude regular expression
Latitude string = "^(\\+|-)?(?:90(?:(?:\\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\\.[0-9]{1,6})?))$"
Latitude string = "^[-+]?(?:[1-8]?\\d(?:\\.\\d+)?|90(?:\\.0+)?)$"
// Longitude represents longitude regular expression
Longitude string = "^(\\+|-)?(?:180(?:(?:\\.0{1,6})?)|(?:[0-9]|[1-9][0-9]|1[0-7][0-9])(?:(?:\\.[0-9]{1,6})?))$"
Longitude string = "^[-+]?(?:180(?:\\.0+)?|(?:(?:1[0-7]\\d)|(?:[1-9]?\\d))(?:\\.\\d+)?)$"
// MacAddress represents regular expression for mac address
MacAddress string = "^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$"
// Numeric represents regular expression for numeric
Expand Down
2 changes: 1 addition & 1 deletion rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ func init() {
if message != "" {
return errors.New(message)
}
return fmt.Errorf("The %s field must be minimum %d in size", field, lenInt)
return fmt.Errorf("The %s field must be maximum %d in size", field, lenInt)
}
case reflect.Int:
in := value.(int)
Expand Down