I'm trying to make a custom validation, so I've made a function that runs in a changeset but I'm getting an error that doesn't seem to make much sense to me at the moment.
Here is my model:
@required_fields ~w(commissioner user_id league_id)a
def changeset(struct, params \\ %{}) do
struct
|> cast(params, @required_fields)
|> validate_required(@required_fields)
|> duplicate_check
end
def duplicate_check(_struct) do
IEx.pry
end
But when I run this code I get this error:
ERROR:
expected a map, got: :ok
BadMapError at GET /leagues/new
_struct
fromduplicate_check
.IEx.pry
returns:ok
so it's probably that. – Dogbert