Added a method to validate IPs.