Created
September 21, 2017 10:38
-
-
Save adamgavlak/1df9d226d14cb236bcf0c7d13b067f39 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Foo.Helpers.UrlValidator do | |
def validate(url) do | |
case URI.parse(url) do | |
%URI{scheme: nil} -> {:error, "No scheme"} | |
%URI{host: nil} -> {:error, "No host"} | |
_ -> {:ok, url} | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment