Created
March 28, 2022 08:36
-
-
Save wttj-tech/5cc64eb737034361e83c55f1f5ea3d3a to your computer and use it in GitHub Desktop.
Password validations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule User do | |
def changeset(user, attrs) do | |
user | |
|> cast(attrs, [:password]) | |
|> validate_length(:password, min: 12) | |
|> 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") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment