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

Link to this section 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.

Link to this section Functions

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

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

Specs

gt(atom()) :: {:gt, atom()}

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

iex> Request.Validator.Helper.gt(:age)

iex> Request.Validator.Helper.gt(:year)

Specs

in_list([any()]) :: {:in_list, [any()]}

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

iex> Request.Validator.Helper.in_list(["male", "female"])

iex> Request.Validator.Helper.in_list(~w[tech law finance])

iex> Request.Validator.Helper.in_list(~w[doctor nurse nurse midwife specialist midwife doctor])

Specs

lt(atom()) :: {:lt, atom()}

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

iex> Request.Validator.Helper.lt(:age)

iex> Request.Validator.Helper.lt(:year)

Specs

max(number()) :: {:max, number()}

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

iex> Request.Validator.Helper.max(30)

iex> Request.Validator.Helper.max(40)

Specs

min(number()) :: {:min, number()}

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

iex> Request.Validator.Helper.min(30)

iex> Request.Validator.Helper.min(40)

Makes a nested map input validation nullable.

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

A wrapper around the required rule.

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}]

Specs

size(number()) :: {:size, number()}

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

iex> Request.Validator.Helper.size(30)

iex> Request.Validator.Helper.size(40)

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

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