AntlUtilsEcto.Changeset (antl_utils_ecto v2.13.2)
View SourceSet of utils for Ecto.Changeset
Summary
Functions
A helper that transforms changeset errors into a map of messages.
A helper that convert changeset error to string (as json encoded format).
A helper that allows to apply function on a changeset only if it is valid. Always returns the changeset
Validates the given fields change are empty or unchanged.
Functions
@spec 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)
@spec json_encode_errors(Ecto.Changeset.t()) :: String.t()
A helper that convert changeset error to string (as json encoded format).
@spec on_valid_changeset(Ecto.Changeset.t(), (Ecto.Changeset.t() -> Ecto.Changeset.t())) :: Ecto.Changeset.t()
A helper that allows to apply function on a changeset only if it is valid. Always returns the changeset
@spec validate_datetime_gt( Ecto.Changeset.t(), atom(), atom() | nil | DateTime.t(), keyword() ) :: Ecto.Changeset.t()
@spec validate_datetime_gte( Ecto.Changeset.t(), atom(), atom() | nil | DateTime.t(), keyword() ) :: Ecto.Changeset.t()
@spec validate_datetime_inclusion( Ecto.Changeset.t(), atom(), atom(), AntlUtilsElixir.DateTime.Period.t() ) :: Ecto.Changeset.t()
@spec validate_datetime_inclusion( Ecto.Changeset.t(), atom(), atom(), map(), atom(), atom() ) :: Ecto.Changeset.t()
@spec validate_datetime_lt( Ecto.Changeset.t(), atom(), atom() | nil | DateTime.t(), keyword() ) :: Ecto.Changeset.t()
@spec validate_datetime_lte( Ecto.Changeset.t(), atom(), atom() | nil | DateTime.t(), keyword() ) :: Ecto.Changeset.t()
@spec validate_empty(Ecto.Changeset.t(), any(), keyword()) :: Ecto.Changeset.t()
Validates the given fields change are empty or unchanged.
@spec validate_empty_if(Ecto.Changeset.t(), any(), atom(), any(), keyword()) :: Ecto.Changeset.t()
@spec validate_empty_unless(Ecto.Changeset.t(), any(), atom(), any(), keyword()) :: Ecto.Changeset.t()
@spec validate_empty_with(Ecto.Changeset.t(), any(), atom() | [atom()], keyword()) :: Ecto.Changeset.t()
@spec validate_empty_with_all(Ecto.Changeset.t(), any(), [atom()], keyword()) :: Ecto.Changeset.t()
@spec validate_empty_without(Ecto.Changeset.t(), any(), atom() | [atom()], keyword()) :: Ecto.Changeset.t()
@spec validate_empty_without_all(Ecto.Changeset.t(), any(), [atom()], keyword()) :: Ecto.Changeset.t()
@spec validate_required_any(Ecto.Changeset.t(), list(), keyword()) :: Ecto.Changeset.t()
@spec validate_required_any_if(Ecto.Changeset.t(), any(), atom(), any(), keyword()) :: Ecto.Changeset.t()
@spec validate_required_any_unless( Ecto.Changeset.t(), any(), atom(), any(), keyword() ) :: Ecto.Changeset.t()
@spec validate_required_if(Ecto.Changeset.t(), any(), atom(), any(), keyword()) :: Ecto.Changeset.t()
@spec validate_required_if_any(Ecto.Changeset.t(), any(), atom(), list(), keyword()) :: Ecto.Changeset.t()
@spec validate_required_one_exclusive(Ecto.Changeset.t(), [any()], keyword()) :: Ecto.Changeset.t()
@spec validate_required_unless(Ecto.Changeset.t(), any(), atom(), any(), keyword()) :: Ecto.Changeset.t()
@spec validate_required_with(Ecto.Changeset.t(), any(), atom() | [atom()], keyword()) :: Ecto.Changeset.t()
@spec validate_required_with_all(Ecto.Changeset.t(), any(), [atom()], keyword()) :: Ecto.Changeset.t()
@spec validate_required_without( Ecto.Changeset.t(), any(), atom() | [atom()], keyword() ) :: Ecto.Changeset.t()
@spec validate_required_without_all(Ecto.Changeset.t(), any(), [atom()], keyword()) :: Ecto.Changeset.t()