mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-08 14:42:27 +08:00
feat(validator): add IsIpPort (#294)
* fix: json tag omitempty convert error * feat(validator): add IsIpPort - Add IsIpPort function to check if a string is in the format ip:port - Update validator_test.go to include tests for the new IsIpPort function - Add an example test for IsIpPort in validator_example_test.go
This commit is contained in:
@@ -348,6 +348,24 @@ func ExampleIsIp() {
|
||||
// false
|
||||
}
|
||||
|
||||
func ExampleIsIpPort() {
|
||||
result1 := IsIpPort("127.0.0.1:8080")
|
||||
result2 := IsIpPort("[0:0:0:0:0:0:0:1]:8080")
|
||||
result3 := IsIpPort(":8080")
|
||||
result4 := IsIpPort("::0:0:0:0:")
|
||||
|
||||
fmt.Println(result1)
|
||||
fmt.Println(result2)
|
||||
fmt.Println(result3)
|
||||
fmt.Println(result4)
|
||||
|
||||
// Output:
|
||||
// true
|
||||
// true
|
||||
// false
|
||||
// false
|
||||
}
|
||||
|
||||
func ExampleIsIpV4() {
|
||||
result1 := IsIpV4("127.0.0.1")
|
||||
result2 := IsIpV4("::0:0:0:0:0:0:1")
|
||||
|
||||
Reference in New Issue
Block a user