From 5991a468ac7a1db8210cc988e8e8070cb3d0a762 Mon Sep 17 00:00:00 2001 From: technicalcapt Date: Mon, 19 Dec 2016 10:56:23 +0700 Subject: [PATCH] remove warning cast/4 deprecated --- lib/addict/interactors/validate_user_for_registration.ex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/addict/interactors/validate_user_for_registration.ex b/lib/addict/interactors/validate_user_for_registration.ex index 6db3a2d..00601c3 100644 --- a/lib/addict/interactors/validate_user_for_registration.ex +++ b/lib/addict/interactors/validate_user_for_registration.ex @@ -19,7 +19,8 @@ Returns `{:ok, []}` or `{:error, [errors]}` def call(user_params, configs \\ Addict.Configs) do struct(configs.user_schema) - |> cast(user_params, ~w(email), ~w()) + |> cast(user_params, [:email]) + |> validate_required(:email) |> validate_format(:email, ~r/.+@.+/) |> unique_constraint(:email) |> validate_password(user_params["password"], configs.password_strategies) @@ -37,7 +38,8 @@ Returns `{:ok, []}` or `{:error, [errors]}` defp validate_password(changeset, password, password_strategies) do %Addict.PasswordUser{} - |> Ecto.Changeset.cast(%{password: password}, ~w(password), []) + |> Ecto.Changeset.cast(%{password: password}, [:password]) + |> Ecto.Changeset.validate_required(:password) |> ValidatePassword.call(password_strategies) |> do_validate_password(changeset.errors) end