View Source Request.Validator.Helper (RequestValidator v0.8.5)

Summary

Functions

A wrapper around the {:exists, callback} rule.

A wrapper around the {:gt, field} rule.

A wrapper around the {:in_list, options} rule.

A wrapper around the {:lt, field} rule.

A wrapper around the {:max, value} rule.

A wrapper around the {:min, value} rule.

Makes a nested map input validation nullable.

A wrapper around the required rule.

A wrapper around the {:size, value} rule.

A wrapper around the {:unique, callback} rule.

Functions

A wrapper around the {:exists, callback} rule.

Examples

iex> alias Request.Validator.Helper
Request.Validator.Helper
iex> {:exists, _} = Helper.exists(&(&1 == 10))
@spec gt(atom()) :: {:gt, atom()}

A wrapper around the {:gt, field} rule.

Examples

iex> Request.Validator.Helper.gt(:age)
{:gt, :age}
iex> Request.Validator.Helper.gt(:year)
{:gt, :year}
@spec in_list([any()]) :: {:in_list, [any()]}

A wrapper around the {:in_list, options} rule.

Examples

iex> Request.Validator.Helper.in_list(["male", "female"])
{:in_list, ~w[male female]}
iex> Request.Validator.Helper.in_list(~w[tech law finance])
{:in_list, ["tech", "law", "finance"]}
iex> Request.Validator.Helper.in_list(~w[doctor nurse nurse midwife specialist midwife doctor])
{:in_list, ~w[doctor nurse midwife specialist]}
@spec lt(atom()) :: {:lt, atom()}

A wrapper around the {:lt, field} rule.

Examples

iex> Request.Validator.Helper.lt(:age)
{:lt, :age}
iex> Request.Validator.Helper.lt(:year)
{:lt, :year}
@spec max(number()) :: {:max, number()}

A wrapper around the {:max, value} rule.

Examples

iex> Request.Validator.Helper.max(30)
{:max, 30}
iex> Request.Validator.Helper.max(40)
{:max, 40}
@spec min(number()) :: {:min, number()}

A wrapper around the {:min, value} rule.

Examples

iex> Request.Validator.Helper.min(30)
{:min, 30}
iex> Request.Validator.Helper.min(40)
{:min, 40}

Makes a nested map input validation nullable.

Examples

iex> alias Request.Validator.{Helper, Rules}
[Request.Validator.Helper, Request.Validator.Rules]
iex> Helper.nullable(Rules.map(name: ~w[required string]a))
%Rules.Object{attrs: [name: ~w[required string]a], nullable: true}
iex> Rules.map(name: ~w[required string]a)
%Rules.Object{attrs: [name: ~w[required string]a], nullable: false}

A wrapper around the required rule.

Examples

iex> Request.Validator.Helper.required(:string)
~w[required string]a
iex> Request.Validator.Helper.required([:string, :email, {:max, 100}])
[:required, :string, :email, {:max, 100}]
iex> Request.Validator.Helper.required({:max, 100})
[:required, {:max, 100}]
@spec size(number()) :: {:size, number()}

A wrapper around the {:size, value} rule.

Examples

iex> Request.Validator.Helper.size(30)
{:size, 30}
iex> Request.Validator.Helper.size(40)
{:size, 40}

A wrapper around the {:unique, callback} rule.

Examples

iex> alias Request.Validator.Helper
Request.Validator.Helper
iex> {:unique, _} = Helper.unique(&(&1 == 10))