Permalink
Browse files

Merge pull request #100 from scstarkey/master

is-email? should be case insensitive
  • Loading branch information...
2 parents 0943053 + 998e846 commit 65c950dbb3b5d1d3f0d395b8185bd7ce4dc89c65 @Raynes Raynes committed May 11, 2012
Showing with 8 additions and 1 deletion.
  1. +1 −1 src/noir/validation.clj
  2. +7 −0 test/noir/test/validation.clj
View
@@ -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?
@@ -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.