PhoenixApiToolkit.Ecto.Validators.move_change

You're seeing just the function move_change, go back to PhoenixApiToolkit.Ecto.Validators module for more information.
Link to this function

move_change(changeset, field, new_field, value_mapper \\ &(&1))

View Source

Move a change to another field in the changeset (if its value is not nil). Like Ecto.Changeset.put_change/3, the change is moved without additional validation. Optionally, the value can be mapped using value_mapper, which defaults to the identity function.

Examples

For the implementation of changeset/1, see Elixir.PhoenixApiToolkit.Ecto.Validators.

# there is no effect when there is no change to the field
iex> changeset() |> move_change(:first_name, :last_name)
#Ecto.Changeset<action: nil, changes: %{}, errors: [], data: %{}, valid?: true>

# a change is moved to another field name as-is by default
iex> changeset(%{first_name: "Pan"}) |> move_change(:first_name, :last_name)
#Ecto.Changeset<action: nil, changes: %{last_name: "Pan"}, errors: [], data: %{}, valid?: true>

# an optional value_mapper can be passed to do some processing on the change along the way
iex> changeset(%{first_name: "Pan"}) |> move_change(:first_name, :last_name, & String.upcase(&1))
#Ecto.Changeset<action: nil, changes: %{last_name: "PAN"}, errors: [], data: %{}, valid?: true>