Last active
August 29, 2015 14:11
-
-
Save laser/678f1c8497a4a3fc1da4 to your computer and use it in GitHub Desktop.
Adding validation
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 ensure-text-presence | |
[params] | |
"Ensure (body :text) is present" | |
(if (empty? (params :text)) | |
[nil, "Please provide text for your note"] | |
[params])) | |
(defn ensure-text-length | |
"Ensure that the length of the text is between 1 and 140 characters" | |
[params] | |
(let [c (count (:text params))] | |
(if (or (> 1 c) (< 140 c)) | |
[nil, "Please provide text between 1 and 140 characters in length"] | |
[params]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment