Skip to content

Commit

Permalink
Add a normal validated_password? function
Browse files Browse the repository at this point in the history
if you want to make it more limit do not change the function entries, it need to be very simple and normal
  • Loading branch information
shahryarjb committed Apr 17, 2024
1 parent 32b9b3b commit 12152f2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/helper/extra.ex
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ defmodule MishkaDeveloperTools.Helper.Extra do

def validated_user?(_username), do: false

def validated_password?(password) when is_binary(password) do
regex_pattern = ~r/^[0-9A-Za-z@#$%^_\-!(,)*]{9,130}$/

Enum.all?([
Regex.match?(regex_pattern, password),
Regex.match?(~r/[A-Z]/, password),
Regex.match?(~r/[a-z]/, password),
Regex.match?(~r/\d/, password),
Regex.match?(~r/[@#$%^_\-!(,)*]/, password)
])
end

def validated_password?(_password), do: false

defp check_specific_characters?(input, allowed_chars) do
input
|> String.to_charlist()
Expand Down

0 comments on commit 12152f2

Please sign in to comment.