Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR ELIXIR

extract changeset error elixir

defmodule Project.Helpers.Error do

  @doc """
    This method is used to extract changeset information for putting into flash notices
  """
  def extract_changeset_error(changeset) do
    [ {field, {description, [{_, validation} | _]}} | _] = changeset.errors
    Macro.camelize("#{field} #{description}. It is #{validation}. ")
  end

end
 
PREVIOUS NEXT
Tagged: #extract #changeset #error #elixir
ADD COMMENT
Topic
Name
5+1 =