Phone Number Validator API - Ruby Gem

Phone Number Validator is a simple tool for validating if a phone number is valid or not. It checks the phone number format and the country code to see if the phone number is valid.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_phonenumbervalidator'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_phonenumbervalidator

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_phonenumbervalidator'

# Initialize the client
client = APIVerve::Phonenumbervalidator::Client.new(api_key: "YOUR_API_KEY")

# Make a request
response = client.execute({
  number: "816-555-1017",
  country: "us"
})

# Print the response
puts response

Error Handling

begin
  response = client.execute({ number: "816-555-1017", country: "us" })
  puts response["data"]
rescue APIVerve::Phonenumbervalidator::ValidationError => e
  puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Phonenumbervalidator::APIError => e
  puts "API error: #{e.message}"
  puts "Status code: #{e.status_code}"
end

Debug Mode

# Enable debug logging
client = APIVerve::Phonenumbervalidator::Client.new(
  api_key: "YOUR_API_KEY",
  debug: true
)

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "country": "US",
    "detectedCountry": "US",
    "countryName": "United States",
    "countrycode": 1,
    "numberNational": 8165551017,
    "extension": null,
    "isValid": true,
    "isMobile": true,
    "isVoip": false,
    "isDisposable": false,
    "type": "fixed_line_or_mobile",
    "formatted": {
      "international": "+1 816-555-1017",
      "national": "(816) 555-1017",
      "rfc": "tel:+1-816-555-1017",
      "e164": "+18165551017"
    },
    "riskScore": 0,
    "riskLevel": "low"
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.