Skip to content

Instantly share code, notes, and snippets.

@adamgavlak
Created September 21, 2017 10:38
Show Gist options
  • Save adamgavlak/1df9d226d14cb236bcf0c7d13b067f39 to your computer and use it in GitHub Desktop.
Save adamgavlak/1df9d226d14cb236bcf0c7d13b067f39 to your computer and use it in GitHub Desktop.
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