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

View File

@ -63,7 +63,7 @@ defmodule Outlook.HtmlPreparations.HtmlPreparation do
def set_sibling_with([ node | rest ]) do def set_sibling_with([ node | rest ]) do
sib_with = case node.type do sib_with = case node.type do
:text -> Regex.match?(~r/^\s*$/, node.content) && :both || :inline :text -> Regex.match?(~r/^\s*$/u, node.content) && :both || :inline
:comment -> :both :comment -> :both
end end
[ %InternalNode{ node | eph: %{sibling_with: sib_with} } | set_sibling_with(rest) ] [ %InternalNode{ node | eph: %{sibling_with: sib_with} } | set_sibling_with(rest) ]
@ -73,7 +73,7 @@ defmodule Outlook.HtmlPreparations.HtmlPreparation do
def strip_whitespace_textnodes [ %{type: :text} = node | rest] do def strip_whitespace_textnodes [ %{type: :text} = node | rest] do
if Regex.match?(~r/^\s*$/, node.content) do if Regex.match?(~r/^\s*$/u, node.content) do
strip_whitespace_textnodes(rest) strip_whitespace_textnodes(rest)
else else
[ node | strip_whitespace_textnodes(rest)] [ node | strip_whitespace_textnodes(rest)]