litmus v0.5.0 Litmus.Type.DateTime View Source
This type validates and converts ISO-8601 datetime with timezone strings into
DateTime
s.
Options
:required
- Setting:required
totrue
will cause a validation error when a field is not present or the value isnil
. Allowed values for required aretrue
andfalse
. The default isfalse
.
Examples
iex> schema = %{"start_date" => %Litmus.Type.DateTime{}}
iex> {:ok, %{"start_date" => datetime}} = Litmus.validate(%{"start_date" => "2017-06-18T05:45:33Z"}, schema)
iex> datetime
#DateTime<2017-06-18 05:45:33Z>