In hexpm project, The line cast(%User{}, params, ~w(username full_name password)a)
.
I know it may be equal to [:username, :full_name,:password], but why?
What's the meaning of ~w
and a
?
def build(params, confirmed? \\ not Application.get_env(:hexpm, :user_confirm)) do
cast(%User{}, params, ~w(username full_name password)a)
|> validate_required(~w(username password)a)
|> cast_assoc(:emails, required: true, with: &Email.changeset(&1, :first, &2, confirmed?))
|> cast_embed(:tfa)
|> update_change(:username, &String.downcase/1)
|> validate_length(:username, min: 3)
|> validate_format(:username, @username_regex)
|> validate_format(:username, @username_reject_regex)
|> validate_exclusion(:username, @reserved_names)
|> unique_constraint(:username, name: "users_username_idx")
|> validate_length(:password, min: 7)
|> validate_confirmation(:password, message: "does not match password")
|> update_change(:password, &Auth.gen_password/1)
end