defmodule Bwc.Player do
  use Ecto.Schema
  import Ecto.Changeset

  schema "players" do
    field :username, :string
    field :picture, :string
  end

  def changeset(player, attrs \\ %{}) do
    player
    |> cast(attrs, [:username, :picture])
    |> validate_required(:username)
    |> unique_constraint(:username)
    |> validate_length(:username, min: 3, max: 20)
  end

end
