aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/validations
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2016-07-24 21:23:23 +0200
committerXavier Noria <fxn@hashref.com>2016-07-24 21:23:23 +0200
commit5a83f054244288032a7c41c13c870674e61b14ae (patch)
tree2c8a54524901499b140c28d6e6abe1a85d7b6e76 /activemodel/lib/active_model/validations
parent56527bb737eb5e1d5531cafe99ce91d025565ead (diff)
downloadrails-5a83f054244288032a7c41c13c870674e61b14ae.tar.gz
rails-5a83f054244288032a7c41c13c870674e61b14ae.tar.bz2
rails-5a83f054244288032a7c41c13c870674e61b14ae.zip
systematic revision of =~ usage in AMo
Diffstat (limited to 'activemodel/lib/active_model/validations')
-rw-r--r--activemodel/lib/active_model/validations/format.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/validations/format.rb b/activemodel/lib/active_model/validations/format.rb
index 46a2e54fba..70799aaf23 100644
--- a/activemodel/lib/active_model/validations/format.rb
+++ b/activemodel/lib/active_model/validations/format.rb
@@ -1,5 +1,6 @@
-module ActiveModel
+require 'active_support/core_ext/regexp'
+module ActiveModel
module Validations
class FormatValidator < EachValidator # :nodoc:
def validate_each(record, attribute, value)
@@ -8,7 +9,7 @@ module ActiveModel
record_error(record, attribute, :with, value) if value.to_s !~ regexp
elsif options[:without]
regexp = option_call(record, :without)
- record_error(record, attribute, :without, value) if value.to_s =~ regexp
+ record_error(record, attribute, :without, value) if regexp.match?(value.to_s)
end
end