7cf9b4e7f8
- spec public functions (skipping controllers, views, live views and components) - use types instead of explanations in docs - remove redundant docs - fix typos
23 lines
468 B
Elixir
23 lines
468 B
Elixir
defmodule LastFm.Album do
|
|
use Ecto.Schema
|
|
|
|
import Ecto.Changeset
|
|
|
|
@type t :: %__MODULE__{
|
|
musicbrainz_id: String.t(),
|
|
title: String.t()
|
|
}
|
|
@primary_key false
|
|
embedded_schema do
|
|
field :musicbrainz_id, :string
|
|
field :title, :string
|
|
end
|
|
|
|
@spec changeset(t(), map()) :: Ecto.Changeset.t()
|
|
def changeset(album, attrs) do
|
|
album
|
|
|> cast(attrs, [:musicbrainz_id, :title])
|
|
|> validate_required([:title])
|
|
end
|
|
end
|