Skip to content

Instantly share code, notes, and snippets.

@jorgevilaca82
Created January 19, 2023 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorgevilaca82/abc9118180db5a1fd83e0387dab747c1 to your computer and use it in GitHub Desktop.
Save jorgevilaca82/abc9118180db5a1fd83e0387dab747c1 to your computer and use it in GitHub Desktop.
check for blank values
defmodule Utils do
def is_blank(nil), do: true
def is_blank(val) when val == %{}, do: true
def is_blank(val) when val == [], do: true
def is_blank(val) when is_binary(val), do: String.trim(val) == ""
def is_blank(val), do: false
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment