Sha256: 70556e26fafa1713898cbd4c571bc95526ac98200cfed020f773506c08137951

Contents?: true

Size: 730 Bytes

Versions: 16

Compression:

Stored size: 730 Bytes

Contents

class PhoneNumberValidator::Validator
  PHONE_NUMBER_REGEX = /^(?:(?:[2-9]11)|(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:\x20+|#|x\.?|ext\.?|extension)\s*(\d+))?)$/i
  def initialize(phone_number = '+1 (949) 355-6244 ext. 198842')
    @phone_number = phone_number
  end
  def validate_phone_number
    if (@phone_number.match(PHONE_NUMBER_REGEX))
      puts "'%s' is a valid phone number." % @phone_number
      return true
    else
      puts "'%s' is not a valid phone number." % @phone_number
      return false
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
phone_number_validator-0.1.5 lib/phone_number_validator/validator.rb
phone_number_validator-0.1.4 lib/phone_number_validator/validator.rb
phone_number_validator-0.1.3 lib/phone_number_validator/validator.rb
phone_number_validator-0.1.2 lib/phone_number_validator/validator.rb
phone_number_validator-0.1.1 lib/phone_number_validator/validator.rb
phone_number_validator-0.1.0 lib/phone_number_validator/validator.rb
phone_number_validator-0.0.9 lib/phone_number_validator/validator.rb
phone_number_validator-0.0.8 lib/phone_number_validator/validator.rb
phone_number_validator-0.0.7 lib/phone_number_validator/validator.rb
phone_number_validator-0.0.6 lib/phone_number_validator/validator.rb
phone_number_validator-0.0.5 lib/phone_number_validator/validator.rb
phone_number_validator-0.0.4 lib/phone_number_validator/validator.rb
phone_number_validator-0.0.3 lib/phone_number_validator/validator.rb
phone_number_validator-0.0.2 lib/phone_number_validator/validator.rb
phone_number_validator-0.0.1 lib/phone_number_validator/validator.rb
phone_number_validator-0.0.0 lib/phone_number_validator/validator.rb