1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-10 15:52:27 +08:00

update: update validator test function

This commit is contained in:
dudaodong
2021-11-29 15:53:48 +08:00
parent 7d39d1319b
commit fee6cb17f3
5 changed files with 10 additions and 14 deletions

View File

@@ -26,11 +26,7 @@ func IsNumberStr(s string) bool {
// IsFloatStr check if the string can convert to a float.
func IsFloatStr(s string) bool {
_, e := strconv.ParseFloat(s, 64)
if e != nil {
return false
}
return true
return e == nil
}
// IsIntStr check if the string can convert to a integer.
@@ -42,10 +38,7 @@ func IsIntStr(s string) bool {
// IsIp check if the string is a ip address.
func IsIp(ipstr string) bool {
ip := net.ParseIP(ipstr)
if ip == nil {
return false
}
return true
return ip != nil
}
// IsIpV4 check if the string is a ipv4 address.