Skip to content

Commit

Permalink
adds validate_required check for web/models/user.ex thanks to @untra in
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Mar 6, 2017
1 parent cfe5333 commit 7d222ef
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion rumbl/web/models/user.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ defmodule Rumbl.User do
def changeset(model, params \\ :empty) do
model
|> cast(params, ~w(name username))
|> validate_required([:name, :username])
|> validate_length(:username, min: 1, max: 20)
|> unique_constraint(:username)
|> unique_constraint(:username) # save unique_constraint for last as DB call
end

def registration_changeset(model, params) do
Expand Down

0 comments on commit 7d222ef

Please sign in to comment.