-
Notifications
You must be signed in to change notification settings - Fork 984
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: password-strength to be consistent for create/change password
- Loading branch information
1 parent
4b34682
commit de0b073
Showing
4 changed files
with
44 additions
and
33 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
(ns status-im.common.validation.password | ||
(:require | ||
[status-im.constants :as constants] | ||
[utils.string :as utils.string])) | ||
|
||
(defn validate-short-enough? | ||
[password] | ||
(utils.string/at-least-n-chars? password | ||
constants/new-password-min-length)) | ||
|
||
(defn validate-long-enough? | ||
[password] | ||
(and (validate-short-enough? password) | ||
(utils.string/at-most-n-chars? password | ||
constants/new-password-max-length))) | ||
|
||
(defn validate | ||
[password] | ||
(let [validations (juxt | ||
utils.string/has-lower-case? | ||
utils.string/has-upper-case? | ||
utils.string/has-numbers? | ||
utils.string/has-symbols? | ||
validate-short-enough? | ||
validate-long-enough?)] | ||
(->> password | ||
validations | ||
(zipmap constants/password-tips)))) |
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
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
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