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
defmodule FinanceWeb.ErrorHelpers do | |
@moduledoc """ | |
Conveniences for translating and building error messages. | |
""" | |
use Phoenix.HTML | |
@doc """ | |
Generates tag for inlined form input 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
Enum.map(error.opts, fn {key, value} -> | |
{String.to_existing_atom(key), value} | |
end) |
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
def get_message(error) do | |
converted_opts = Enum.map(error.opts, fn {key, value} -> | |
{String.to_existing_atom(key), value} | |
end) | |
translate_error({"#{error.message}", converted_opts}) | |
end |
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
def create!(attrs) do | |
%{attrs | message_opts: Map.new(attrs.message_opts)} | |
|> SourceFileError.changeset() | |
|> Repo.insert!() | |
end |
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
%{example_map | key: updated_value} |
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
Map.put/3 | |
Map.replace!/3 | |
Map.update!/3 | |
Map.update/4 |
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
[kind: :less_than_or_equal_to, number: 0, validation: :number] |
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
%{"kind": "less_than_or_equal_to", "number": 0, "validation": "number"} |
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
%{"kind" => "less_than_or_equal_to", "number" => 0, "validation" => "number"} |
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
[kind: "less_than_or_equal_to", number: 0, validation: "number"] |