Skip to content

Commit 12152f2

Browse files
committed
Add a normal validated_password? function
if you want to make it more limit do not change the function entries, it need to be very simple and normal
1 parent 32b9b3b commit 12152f2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/helper/extra.ex

+14
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ defmodule MishkaDeveloperTools.Helper.Extra do
6161

6262
def validated_user?(_username), do: false
6363

64+
def validated_password?(password) when is_binary(password) do
65+
regex_pattern = ~r/^[0-9A-Za-z@#$%^_\-!(,)*]{9,130}$/
66+
67+
Enum.all?([
68+
Regex.match?(regex_pattern, password),
69+
Regex.match?(~r/[A-Z]/, password),
70+
Regex.match?(~r/[a-z]/, password),
71+
Regex.match?(~r/\d/, password),
72+
Regex.match?(~r/[@#$%^_\-!(,)*]/, password)
73+
])
74+
end
75+
76+
def validated_password?(_password), do: false
77+
6478
defp check_specific_characters?(input, allowed_chars) do
6579
input
6680
|> String.to_charlist()

0 commit comments

Comments
 (0)