API Reference Draft v1.0.2
modules
Modules
Data Validation for Elixir.
Implementation of this behaviour should be set in validator options as :error_renderer
or in :draft
application config with same key.
Common pattern is to expect :message
key in validator options and if it not set
use default_message
(use get_message
function for it).
Result of message
function appears in Draft.errors
error tuple as last element, for those
validators who use Draft.Validator.ErrorMessage
(in general they should).
example
example
iex> {:ok, _value} = Draft.Type.Datetime.cast("01-01-1900", [])
iex> {:ok, _value} = Draft.Type.Datetime.cast("1900-01-01", [])
iex> {:ok, _value} = Draft.Type.Datetime.cast("2016-02-29T22:25:00-06:00", [])
iex> {:ok, _value} = Draft.Type.Datetime.cast("2023-02-01T14:51:53.468132Z", [])
iex> {:error, _reason} = Draft.Type.Datetime.cast("1900-91-91", [])
Common validator behavior.
Ensure a value is not a member of a list of values.
Ensure a value matches a regular expression.
Ensure a value is a member of a list of values.
Ensure a value's length meets a constraint.
Ensure a value's value meets a constraint.
Ensure a value's value meets a constraint.
Ensure a value is a number.