litmus v0.5.0 Litmus.Type.DateTime View Source

This type validates and converts ISO-8601 datetime with timezone strings into DateTimes.

Options

  • :required - Setting :required to true will cause a validation error when a field is not present or the value is nil. Allowed values for required are true and false. The default is false.

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>

Link to this section Summary

Link to this section Types

Link to this type t() View Source
t() :: %Litmus.Type.DateTime{required: boolean()}

Link to this section Functions

Link to this function validate_field(type, field, data) View Source
validate_field(t(), String.t(), map()) ::
  {:ok, map()} | {:error, String.t()}