Last active
August 29, 2015 14:15
-
-
Save trikitrok/c031d6b621f28b85ce0d to your computer and use it in GitHub Desktop.
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
(ns password-validator.core) | |
(defn- has-more-than-6-chars? [password] | |
(> (count password) 6)) | |
(defn- any? [pred coll] | |
(not= nil (some pred coll))) | |
(def ^:private contains-at-least-one-upper-case-char? | |
(partial any? #(Character/isUpperCase %))) | |
(def ^:private contains-at-least-one-lower-case-char? | |
(partial any? #(Character/isLowerCase %))) | |
(def ^:private contains-at-least-one-underscore-char? | |
(partial any? #{\_})) | |
(def ^:private contains-at-least-one-numeric-char? | |
(partial any? #(Character/isDigit %))) | |
(def ^:private conditions-to-be-valid | |
[has-more-than-6-chars? | |
contains-at-least-one-upper-case-char? | |
contains-at-least-one-lower-case-char? | |
contains-at-least-one-underscore-char? | |
contains-at-least-one-numeric-char?]) | |
(defn valid? [password] | |
(every? #(% password) conditions-to-be-valid)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment