From 892dc85ed4bdae4b83218693ef6dc3726da80252 Mon Sep 17 00:00:00 2001 From: Filipp Molchanov Date: Fri, 15 Nov 2024 21:38:31 +0300 Subject: [PATCH] Fix documentation examples for casting empty values (#4550) --- lib/ecto/changeset.ex | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/ecto/changeset.ex b/lib/ecto/changeset.ex index cd0daeffe9..48e412baf5 100644 --- a/lib/ecto/changeset.ex +++ b/lib/ecto/changeset.ex @@ -664,21 +664,21 @@ defmodule Ecto.Changeset do # Using default iex> params = %{title: "", topics: []} - iex> changeset = cast(post, params, [:title, :topics]) - iex> changeset.params + iex> changeset = cast(%Post{}, params, [:title, :topics]) + iex> changeset.changes %{topics: []} # Changing default iex> params = %{title: "", topics: []} - iex> changeset = cast(post, params, [:topics], empty_values: [[], nil]) - iex> changeset.params + iex> changeset = cast(%Post{}, params, [:title, :topics], empty_values: [[], nil]) + iex> changeset.changes %{title: ""} # Augmenting default iex> params = %{title: "", topics: []} iex> changeset = - ...> cast(post, params, [:topics], empty_values: [[], nil] ++ Ecto.Changeset.empty_values()) - iex> changeset.params + ...> cast(%Post{}, params, [:title, :topics], empty_values: [[], nil] ++ Ecto.Changeset.empty_values()) + iex> changeset.changes %{} You can define a custom error message function.