Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated is-email? function to be case insensitive.

  • Loading branch information...
commit 998e846dd44f42b8e01a6977e6d22a3eff5e4542 1 parent 0943053
@scstarkey scstarkey authored
Showing with 8 additions and 1 deletion.
  1. +1 −1  src/noir/validation.clj
  2. +7 −0 test/noir/test/validation.clj
View
2  src/noir/validation.clj
@@ -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?
View
7 test/noir/test/validation.clj
@@ -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"))))
Please sign in to comment.
Something went wrong with that request. Please try again.