Skip to content

Commit

Permalink
Merge pull request #100 from scstarkey/master
Browse files Browse the repository at this point in the history
is-email? should be case insensitive
  • Loading branch information
Raynes committed May 11, 2012
2 parents 0943053 + 998e846 commit 65c950d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/noir/validation.clj
Expand Up @@ -37,7 +37,7 @@
(defn is-email?
"Returns true if v is an email address"
[v]
(re-matches #"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?" v))
(re-matches #"(?i)[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?" v))


(defn valid-file?
Expand Down
7 changes: 7 additions & 0 deletions test/noir/test/validation.clj
Expand Up @@ -16,3 +16,10 @@
(vali/set-error :a "blah")
(vali/set-error :b "cool")
(is (= (set (vali/get-errors)) (set ["blah" "cool"])))))

(deftest is-email-case-insensitive
(with-noir
(is (vali/is-email? "me@here.com"))
(is (vali/is-email? "Me@here.com"))
(is (vali/is-email? "me@Here.coM"))
(is (vali/is-email? "ME@HERE.COM"))))

0 comments on commit 65c950d

Please sign in to comment.