View Source Glific.URI (Glific v5.1.6)

This file has been copied (and modified a wee bit)from https://github.com/jerel/ecto_fields/blob/master/lib/fields/url.ex

The ownership, author and license (MIT) remains with the original owner of that repository

Link to this section Summary

Functions

Validate that the given value is a valid fully qualified url

Link to this section Functions

@spec cast(String.t()) :: :ok | :error

Validate that the given value is a valid fully qualified url

examples

Examples

iex> EctoFields.URL.cast("http://1.1.1.1")
:ok

iex> EctoFields.URL.cast("http://example.com")
:ok

iex> EctoFields.URL.cast("https://example.com")
:ok

iex> EctoFields.URL.cast("http://example.com/test/foo.html?search=1&page=two#header")
:ok

iex> EctoFields.URL.cast("http://example.com:8080/")
:ok

iex> EctoFields.URL.cast("myblog.html")
:error

iex> EctoFields.URL.cast("http://example.comlogirst")
:error