View Source Draft.Validator.Min (Draft v1.0.2)

Ensure a value's value meets a constraint.

examples

Examples

iex> Draft.Validator.Min.validate(3, 3)
{:ok, 3}

iex> Draft.Validator.Min.validate(4, 5)
{:error, "must be greater than 5"}

iex> Draft.Validator.Min.validate("foo", 3)
{:ok, "foo"}

iex> Draft.Validator.Min.validate([1], 3)
{:error, "must be greater than 3"}

iex> Draft.Validator.Min.validate([1, 2, 3], 3)
{:ok, [1, 2, 3]}

iex> Draft.Validator.Min.validate("foo", 4)
{:error, "must be greater than 4"}

iex> Draft.Validator.Min.validate("foo", min: 4, message: "must be the right length")
{:error, "must be the right length"}

Link to this section Summary

Functions

Callback implementation for c:Draft.Validator.Behaviour.validate/2.

Callback implementation for c:Draft.Validator.Behaviour.validate/3.

Link to this section Functions

Callback implementation for c:Draft.Validator.Behaviour.validate/2.

Link to this function

validate(data, context, options)

View Source

Callback implementation for c:Draft.Validator.Behaviour.validate/3.