code and function to validate URL