mobilizon/lib/eventos/events/category.ex
Thomas Citharel 979aad5acb Remove credo and use mix format, and lint everything
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2018-07-27 10:45:35 +02:00

25 lines
529 B
Elixir

defmodule Eventos.Events.Category do
@moduledoc """
Represents a category for events
"""
use Ecto.Schema
import Ecto.Changeset
alias Eventos.Events.Category
schema "categories" do
field(:description, :string)
field(:picture, :string)
field(:title, :string, null: false)
timestamps()
end
@doc false
def changeset(%Category{} = category, attrs) do
category
|> cast(attrs, [:title, :description, :picture])
|> validate_required([:title])
|> unique_constraint(:title)
end
end