I’ve recently needed to use Ecto.Changeset.validate_change and I “think” I may have found a problem in the documentation. The docs state that you should return a list of errors and shows an example [title: “cannot be foo”] but I believe this should be [{title: “cannot be foo”}].
I’ve no experience in raising issues and just wanted to check with you good people that simply raising something on the appropriate Github page is the thing to do.
Hi @NobbZ - when I tried the example I received an error
##### FunctionClauseError <small>at POST</small> <small>/cost_centres</small>
# no function clause matching in anonymous fn/1 in Ecto.Changeset.validate_change/3
My code:
def validate_uppercase(changeset, field) do
IO.puts "about to validate uppercase"
validate_change changeset, field, fn field, value ->
if (String.upcase(value) != value) do
[field, "value must be uppercase"]
else
[]
end
end
end