Created
January 10, 2018 10:11
-
-
Save hopewise/391d854732c2c144c9671a7e9bc79d0b to your computer and use it in GitHub Desktop.
Json encoding Ecto changeset validation errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for result_error <- changeset.errors do | |
{field_name, ecto_error}= result_error | |
{error_message, ecto_validation}= ecto_error | |
[ecto_validation_message| ecto_validation_tail] = ecto_validation | |
ecto_validation_message= Kernel.inspect ecto_validation_message | |
Poison.encode! %{error: "invalid field value", field: %{field_name: field_name, error_message: ecto_validation_message }}) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment