From d1ffe59ab5fd6e811833c127d43b32e87b5d7131 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Sat, 27 Jul 2019 12:56:39 +0900 Subject: Use match? where we don't need MatchData We're already running Performance/RegexpMatch cop, but it seems like the cop is not always =~ justice --- activemodel/lib/active_model/validations/format.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activemodel') diff --git a/activemodel/lib/active_model/validations/format.rb b/activemodel/lib/active_model/validations/format.rb index bea57415b0..a473440b4e 100644 --- a/activemodel/lib/active_model/validations/format.rb +++ b/activemodel/lib/active_model/validations/format.rb @@ -6,7 +6,7 @@ module ActiveModel def validate_each(record, attribute, value) if options[:with] regexp = option_call(record, :with) - record_error(record, attribute, :with, value) if value.to_s !~ regexp + record_error(record, attribute, :with, value) unless regexp.match?(value.to_s) elsif options[:without] regexp = option_call(record, :without) record_error(record, attribute, :without, value) if regexp.match?(value.to_s) -- cgit v1.2.3