Update regexes with u option

And add pw validations
This commit is contained in:
Thelonius Kort
2023-02-14 20:56:57 +01:00
parent 66a61c8380
commit 7297a907da
2 changed files with 7 additions and 7 deletions

View File

@ -45,7 +45,7 @@ defmodule Outlook.Accounts.User do
defp validate_email(changeset, opts) do
changeset
|> validate_required([:email])
|> validate_format(:email, ~r/^[^\s]+@[^\s]+$/, message: "must have the @ sign and no spaces")
|> validate_format(:email, ~r/^[^\s]+@[^\s]+$/u, message: "must have the @ sign and no spaces")
|> validate_length(:email, max: 160)
|> maybe_validate_unique_email(opts)
end
@ -53,10 +53,10 @@ defmodule Outlook.Accounts.User do
defp validate_password(changeset, opts) do
changeset
|> validate_required([:password])
|> validate_length(:password, min: 12, max: 72)
# |> validate_format(:password, ~r/[a-z]/, message: "at least one lower case character")
# |> validate_format(:password, ~r/[A-Z]/, message: "at least one upper case character")
# |> validate_format(:password, ~r/[!?@#$%^&*_0-9]/, message: "at least one digit or punctuation character")
|> validate_length(:password, min: 8, max: 72)
|> validate_format(:password, ~r/[a-z]/u, message: "at least one lower case character")
|> validate_format(:password, ~r/[A-Z]/u, message: "at least one upper case character")
|> validate_format(:password, ~r/[!?@#$%^&*_0-9]/u, message: "at least one digit or punctuation character")
|> maybe_hash_password(opts)
end