Add restriction on names

This commit is contained in:
dtluna 2017-04-24 15:33:27 +03:00
parent a3b9741a62
commit 668b01da0b

View file

@ -63,6 +63,7 @@ def register_changeset(struct, params \\ %{}) do
|> validate_confirmation(:password) |> validate_confirmation(:password)
|> unique_constraint(:email) |> unique_constraint(:email)
|> unique_constraint(:nickname) |> unique_constraint(:nickname)
|> validate_format(:nickname, ~r/^[a-zA-Z\d]+$/)
if changeset.valid? do if changeset.valid? do
hashed = Comeonin.Pbkdf2.hashpwsalt(changeset.changes[:password]) hashed = Comeonin.Pbkdf2.hashpwsalt(changeset.changes[:password])