Exop v0.4.6 Exop.Validation

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

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

Types

validation_error :: {:error, {:validation, map}}

Functions

check_inner(check_items, item_name, cheks)

Specs

check_inner(map | Keyword.t, atom, 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
errors_message(errors)

Specs

errors_message(map) :: String.t
valid?(contract, received_params)

Specs

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
validate(list, received_params, result)

Specs

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]