Exop v1.2.2 Exop.Validation View Source

Provides high-level functions for a contract validation. The main function is valid?/2 Mostly invokes Exop.ValidationChecks module functions.

Link to this section Summary

Functions

Checks inner item of the contract param (which is a Map itself) with their own checks

Validate received params over a contract

Validate received params over a contract. Accumulate validation results into a list

Link to this section Types

Link to this type validation_error() View Source
validation_error() :: {:error, {:validation, map()}}

Link to this section Functions

Link to this function check_inner(check_items, item_name, checks) View Source
check_inner(map() | Keyword.t(), atom() | String.t(), map() | Keyword.t()) ::
  list()

Checks inner item of the contract param (which is a Map itself) with their own checks.

Examples

iex> Exop.Validation.check_inner(%{param: 1}, :param, [type: :integer, required: true])
true
Link to this function check_list_item(check_items, item_name, checks) View Source
check_list_item(map() | Keyword.t(), atom() | String.t(), map() | Keyword.t()) ::
  list()
Link to this function errors_message(errors) View Source
errors_message(map()) :: String.t()
Link to this function valid?(contract, received_params) View Source
valid?([map()], Keyword.t() | map()) :: :ok | validation_error()

Validate received params over a contract.

Examples

iex> Exop.Validation.valid?([%{name: :param, opts: [required: true]}], [param: "hello"])
:ok
Link to this function validate(list, received_params, result) View Source
validate([map()], map() | Keyword.t(), list()) :: list()

Validate received params over a contract. Accumulate validation results into a list.

Examples

iex> Exop.Validation.validate([%{name: :param, opts: [required: true, type: :string]}], [param: "hello"], [])
[true, true]