diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-09-14 09:38:16 -0600 |
---|---|---|
committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-09-14 09:38:16 -0600 |
commit | 0d4b60520efad059fc387626e1b7e4edf141d7e1 (patch) | |
tree | 06f1c05d1959a6b206bfd77319e775f27c4a3b1e /lib/chessh/schema | |
parent | 87bd117289f6824a61fd30d7633d07d305435924 (diff) | |
download | chessh-0d4b60520efad059fc387626e1b7e4edf141d7e1.tar.gz chessh-0d4b60520efad059fc387626e1b7e4edf141d7e1.zip |
update dependencies and fix discriminator matching on username
Diffstat (limited to 'lib/chessh/schema')
-rw-r--r-- | lib/chessh/schema/player.ex | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/chessh/schema/player.ex b/lib/chessh/schema/player.ex index d5bcab2..19142e9 100644 --- a/lib/chessh/schema/player.ex +++ b/lib/chessh/schema/player.ex @@ -43,6 +43,12 @@ defmodule Chessh.Player do |> validate_discord_id() end + def username_changeset(player, attrs) do + player + |> cast(attrs, [:username]) + |> validate_username() + end + def registration_changeset(player, attrs, opts \\ []) do player |> cast(attrs, [:username, :password, :discord_id]) @@ -85,7 +91,9 @@ defmodule Chessh.Player do changeset |> validate_required([:username]) |> validate_length(:username, min: 2, max: 40) - |> validate_format(:username, ~r/^.{3,32}#[0-9]{4}$/, message: "must match discord tag format") + |> validate_format(:username, ~r/^.{3,32}(#[0-9]{4})?$/, + message: "must match discord tag format" + ) |> unique_constraint(:username) end |