Skip to content

Latest commit

 

History

History
28 lines (21 loc) · 687 Bytes

ip.md

File metadata and controls

28 lines (21 loc) · 687 Bytes

IP Checker

The ip checker checks if the value is an IP address. If the value is not an IP address, the checker will return the NOT_IP result. Here is an example:

type Request struct {
  RemoteIP string `checkers:"ip"`
}

request := &Request{
  RemoteIP: "192.168.1.1",
}

_, valid := checker.Check(request)
if !valid {
  // Send the mistakes back to the user
}

In your custom checkers, you can call the ip checker function IsIP to validate the user input. Here is an example:

result := checker.IsIP("2001:db8::68")

if result != checker.ResultValid {
  // Send the mistakes back to the user
}