Permalink
Browse files

you rarely want ^ or $ in validations, use \A when you mean \A

  • Loading branch information...
1 parent 017840b commit 23303d6ab7c24f3f363a22773017cc15ea358550 @fxn fxn committed Aug 17, 2010
Showing with 2 additions and 2 deletions.
  1. +2 −2 activemodel/lib/active_model/validations/validates.rb
@@ -28,7 +28,7 @@ module ClassMethods
# class EmailValidator < ActiveModel::EachValidator
# def validate_each(record, attribute, value)
# record.errors[attribute] << (options[:message] || "is not an email") unless
- # value =~ /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
+ # value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
# end
# end
#
@@ -48,7 +48,7 @@ module ClassMethods
#
# class TitleValidator < ActiveModel::EachValidator
# def validate_each(record, attribute, value)
- # record.errors[attribute] << "must start with 'the'" unless value =~ /^the/i
+ # record.errors[attribute] << "must start with 'the'" unless value =~ /\Athe/i
# end
# end
#

0 comments on commit 23303d6

Please sign in to comment.