View Source Parameter.Types.Date (Parameter v0.7.1)

Date parameter type

Link to this section Summary

Functions

loads Date type

validate date type

Link to this section Functions

loads Date type

examples

Examples

iex> Parameter.Types.Date.load(%Date{year: 1990, month: 5, day: 1})
{:ok, ~D[1990-05-01]}

iex> Parameter.Types.Date.load({2020, 10, 5})
{:ok, ~D[2020-10-05]}

iex> Parameter.Types.Date.load("2015-01-23")
{:ok, ~D[2015-01-23]}

iex> Parameter.Types.Date.load("2015-25-23")
{:error, "invalid date type"}

validate date type

examples

Examples

iex> Parameter.Types.Date.validate(%Date{year: 1990, month: 5, day: 1})
:ok

iex> Parameter.Types.Date.validate(~D[1990-05-01])
:ok

iex> Parameter.Types.Date.validate("2015-01-23")
{:error, "invalid date type"}