Created
January 8, 2016 23:31
-
-
Save terakilobyte/cc170d6a489ad9d816a5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 validate_categories(%{model: %{categories: nil}} = changeset), do: add_error(changeset, :categories, "must have at least two categories") | |
def validate_categories(%{model: %{categories: categories}} = changeset) when map_size(categories) < 2 do | |
add_error(changeset, :categories, "must have at least two categories") | |
end | |
def validate_categories(changeset), do: changeset | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment