Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/validators/phone_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def validate_each(record, attribute, value)
return if options[:allow_blank] && value.blank?

@phone = parse(value, specified_country(record))
valid = phone_valid? && valid_types? && valid_country? && valid_extensions?
valid = countries.present? ? valid_country? : phone_valid?
valid = valid && valid_types? && valid_extensions?

record.errors.add(attribute, message, options) unless valid
end
Expand All @@ -82,7 +83,7 @@ def valid_types?

def valid_country?
return true unless options[:countries]
(phone_countries & countries).size > 0
countries.any? { |country| @phone.valid_for_country?(country) }
end

def valid_extensions?
Expand Down