Skip to content

Commit

Permalink
fixing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
daddyz committed Sep 17, 2017
1 parent e6aee78 commit 41c7821
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Upcoming Changes (unreleased)

## 0.6.14 - September 17, 2017
## 0.6.15 - September 17, 2017
- updated data
- ```:extensions``` option added to validator, once set to ```false``` will perform additional check if parsed phone has extension

Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
phonelib (0.6.14)
phonelib (0.6.15)

GEM
remote: http://rubygems.org/
Expand Down
2 changes: 1 addition & 1 deletion lib/phonelib/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Phonelib
# @private
VERSION = '0.6.14'
VERSION = '0.6.15'
end
4 changes: 2 additions & 2 deletions lib/validators/phone_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class PhoneValidator < ActiveModel::EachValidator
# Validation method
def validate_each(record, attribute, value)
return if options[:allow_blank] && value.blank?
options[:extensions] ||= true
allowed_extensions = options.has_key?(:extensions) ? options[:extensions] : true

phone = parse(value, specified_country(record))
valid = if simple_validation?
Expand All @@ -61,7 +61,7 @@ def validate_each(record, attribute, value)
end

# We default to not-allowing extensions for fax numbers
if valid && options[:extensions] === false && !phone.extension.empty?
if valid && !allowed_extensions && !phone.extension.empty?
valid = false
end

Expand Down

0 comments on commit 41c7821

Please sign in to comment.