Commit d621467b

mo khan <mo@mokhan.ca>
2014-09-24 02:58:21
move email validator to a separate file.
1 parent c221ecb
Changed files (2)
app/models/email_validator.rb
@@ -0,0 +1,8 @@
+class EmailValidator < ActiveModel::EachValidator
+  def validate_each(record, attribute, value)
+    unless value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
+      record.errors[attribute] << (options[:message] || "is not an email")
+    end
+  end
+end
+
app/models/user.rb
@@ -1,13 +1,5 @@
 require 'bcrypt'
 
-class EmailValidator < ActiveModel::EachValidator
-  def validate_each(record, attribute, value)
-    unless value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
-      record.errors[attribute] << (options[:message] || "is not an email")
-    end
-  end
-end
-
 class User < ActiveRecord::Base
   include BCrypt
   before_save :ensure_authentication_token