Display custom error message in proper format

I have a list of values like this

  result = [:id, :title, :id]

I am using comprehensions to iterate over them and display the error message which looks like this:

    for n <- result, do: {n, "field doesn't exist"}
          id: "field doesn't exist",
          title: "field doesn't exist",
          id: "field doesn't exist"

what I want the output is like this:

        id : "field doesn't exist"

How can I format it like this?


Your for comprehension returns a keyword list, that can be turned into a map using Enum.into/2 then added to the errors map, like: %{errors: resulting_map}
Sorry for lack of a better explanation and examples, I’m on my phone

Thanks for your input.