Use match? instead of match for regex where MatchData is unused

This commit is contained in:
Maciej Szlosarczyk 2018-08-17 10:36:52 +03:00
parent db08ad7125
commit 82dbd3e8b8
No known key found for this signature in database
GPG key ID: 41D62D42D3B0D765
7 changed files with 12 additions and 10 deletions

View file

@ -10,7 +10,9 @@ class Contact::Ident::RegNoValidator < ActiveModel::EachValidator
return unless format
record.errors.add(attribute, :invalid_reg_no, country: record.country) unless value =~ format
unless value.match?(format)
record.errors.add(attribute, :invalid_reg_no, country: record.country)
end
end
private

View file

@ -22,7 +22,7 @@ class DomainNameValidator < ActiveModel::EachValidator
# it's punycode
if value[2] == '-' && value[3] == '-'
regexp = /\Axn--[a-zA-Z0-9-]{0,59}\.#{general_domains}\z/
return false unless value =~ regexp
return false unless value.match?(regexp)
value = SimpleIDN.to_unicode(value).mb_chars.downcase.strip
end