This file contains hidden or 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
# Hello, and welcome to makefile basics. | |
# | |
# You will learn why `make` is so great, and why, despite its "weird" syntax, | |
# it is actually a highly expressive, efficient, and powerful way to build | |
# programs. | |
# | |
# Once you're done here, go to | |
# http://www.gnu.org/software/make/manual/make.html | |
# to learn SOOOO much more. |
This file contains hidden or 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
(defn validates-credentials [username password] | |
(let [uc (count username) | |
pc (count password)] | |
(match [username uc password pc] | |
[(:or nil "") _ _ _] {:error "No username given" :field "name"} | |
[_ _ (:or nil "") _] {:error "No password given" :field "pass"} | |
[_ (_ :guard #(< % 3)) _ _] {:error "Username less than 3 characters" :field "pass"} | |
[_ _ _ (_ :guard #(< % 4))] {:error "Password less than 4 characters" :field "pass"} | |
[#"^([a-z0-9-_]+)$" _ _ _] {:error "Username contains invalid characters" :field "name"} | |
:else true))) |