AntlUtilsEcto.Changeset (antl_utils_ecto v0.1.0)

Link to this section Summary

Functions

A helper that transforms changeset errors into a map of messages.

Validates the given fields change are empty or unchanged.

Link to this section Functions

Link to this function

errors_on(changeset)

Specs

errors_on(Ecto.Changeset.t()) :: %{optional(atom()) => [binary()]}

A helper that transforms changeset errors into a map of messages.

Examples

iex> changeset = Ecto.Changeset.change({%{}, %{password: :string}}) |> Ecto.Changeset.cast(%{password: 123}, [:password]) iex> assert "is invalid" in AntlUtilsEcto.Changeset.errors_on(changeset).password iex> assert %{password: ["is invalid"]} = AntlUtilsEcto.Changeset.errors_on(changeset)

Link to this function

validate_datetime_gt(changeset, datetime_key, referal, opts \\ [])

Specs

validate_datetime_gt(
  Ecto.Changeset.t(),
  atom() | nil | DateTime.t(),
  atom(),
  keyword()
) :: Ecto.Changeset.t()
Link to this function

validate_datetime_gte(changeset, datetime_key, referal, opts \\ [])

Specs

validate_datetime_gte(
  Ecto.Changeset.t(),
  atom() | nil | DateTime.t(),
  atom(),
  keyword()
) :: Ecto.Changeset.t()
Link to this function

validate_datetime_inclusion(changeset, start_at_key, end_at_key, container_period)

Specs

validate_datetime_inclusion(
  Ecto.Changeset.t(),
  atom(),
  atom(),
  AntlUtilsElixir.DateTime.Period.t()
) :: Ecto.Changeset.t()
Link to this function

validate_datetime_inclusion(changeset, start_at_key, end_at_key, period, period_start_at_key, period_end_at_key)

Specs

validate_datetime_inclusion(
  Ecto.Changeset.t(),
  atom(),
  atom(),
  map(),
  atom(),
  atom()
) :: Ecto.Changeset.t()
Link to this function

validate_datetime_lt(changeset, datetime_key, referal, opts \\ [])

Specs

validate_datetime_lt(
  Ecto.Changeset.t(),
  atom(),
  atom() | nil | DateTime.t(),
  keyword()
) :: Ecto.Changeset.t()
Link to this function

validate_datetime_lte(changeset, datetime_key, referal, opts \\ [])

Specs

validate_datetime_lte(
  Ecto.Changeset.t(),
  atom(),
  atom() | nil | DateTime.t(),
  keyword()
) :: Ecto.Changeset.t()
Link to this function

validate_empty(changeset, fields, opts \\ [])

Specs

validate_empty(Ecto.Changeset.t(), any(), keyword()) :: Ecto.Changeset.t()

Validates the given fields change are empty or unchanged.

Link to this function

validate_empty_if(changeset, fields, conditional_field, expected_value, opts \\ [])

Specs

validate_empty_if(Ecto.Changeset.t(), any(), atom(), any(), keyword()) ::
  Ecto.Changeset.t()
Link to this function

validate_empty_unless(changeset, fields, conditional_field, expected_value, opts \\ [])

Specs

validate_empty_unless(Ecto.Changeset.t(), any(), atom(), any(), keyword()) ::
  Ecto.Changeset.t()
Link to this function

validate_empty_with(changeset, fields, conditional_fields, opts \\ [])

Specs

validate_empty_with(Ecto.Changeset.t(), any(), atom() | [atom()], keyword()) ::
  Ecto.Changeset.t()
Link to this function

validate_empty_with_all(changeset, fields, conditional_fields, opts \\ [])

Specs

validate_empty_with_all(Ecto.Changeset.t(), any(), [atom()], keyword()) ::
  Ecto.Changeset.t()
Link to this function

validate_empty_without(changeset, fields, conditional_fields, opts \\ [])

Specs

validate_empty_without(Ecto.Changeset.t(), any(), atom() | [atom()], keyword()) ::
  Ecto.Changeset.t()
Link to this function

validate_empty_without_all(changeset, fields, conditional_fields, opts \\ [])

Specs

validate_empty_without_all(Ecto.Changeset.t(), any(), [atom()], keyword()) ::
  Ecto.Changeset.t()
Link to this function

validate_required_any(changeset, fields, opts \\ [])

Specs

validate_required_any(Ecto.Changeset.t(), list(), keyword()) ::
  Ecto.Changeset.t()
Link to this function

validate_required_any_if(changeset, fields, conditional_field, expected_value, opts \\ [])

Specs

validate_required_any_if(Ecto.Changeset.t(), any(), atom(), any(), keyword()) ::
  Ecto.Changeset.t()
Link to this function

validate_required_any_unless(changeset, fields, conditional_field, expected_value, opts \\ [])

Specs

validate_required_any_unless(
  Ecto.Changeset.t(),
  any(),
  atom(),
  any(),
  keyword()
) :: Ecto.Changeset.t()
Link to this function

validate_required_if(changeset, fields, conditional_field, expected_value, opts \\ [])

Specs

validate_required_if(Ecto.Changeset.t(), any(), atom(), any(), keyword()) ::
  Ecto.Changeset.t()
Link to this function

validate_required_one_exclusive(changeset, fields, opts \\ [])

Specs

validate_required_one_exclusive(Ecto.Changeset.t(), [any()], keyword()) ::
  Ecto.Changeset.t()
Link to this function

validate_required_unless(changeset, fields, conditional_field, expected_value, opts \\ [])

Specs

validate_required_unless(Ecto.Changeset.t(), any(), atom(), any(), keyword()) ::
  Ecto.Changeset.t()
Link to this function

validate_required_with(changeset, fields, conditional_fields, opts \\ [])

Specs

validate_required_with(Ecto.Changeset.t(), any(), atom() | [atom()], keyword()) ::
  Ecto.Changeset.t()
Link to this function

validate_required_with_all(changeset, fields, conditional_fields, opts \\ [])

Specs

validate_required_with_all(Ecto.Changeset.t(), any(), [atom()], keyword()) ::
  Ecto.Changeset.t()
Link to this function

validate_required_without(changeset, fields, conditional_fields, opts \\ [])

Specs

validate_required_without(
  Ecto.Changeset.t(),
  any(),
  atom() | [atom()],
  keyword()
) :: Ecto.Changeset.t()
Link to this function

validate_required_without_all(changeset, fields, conditional_fields, opts \\ [])

Specs

validate_required_without_all(Ecto.Changeset.t(), any(), [atom()], keyword()) ::
  Ecto.Changeset.t()