Skip to content

Repository files navigation

Build Status

AddressValidator

Wrapper around the UPS street level validation API. Nowhere near a complete implementation. This will just give some basic information back, such as address classification (residential/commercial) and if it is valid or not.

This can be modified to include address suggestions pretty easily in the Validator#build_request method, but we have no need of this right now.

Installation

Add this line to your application's Gemfile:

gem 'address_validator', github: 'robhurring/address-validator'

And then execute:

$ bundle

Usage

Configuring the client

AddressValidator.configuredo |config|
config.key='youraccesskeyfromups'config.username='username'config.password='hunter2'config.maximum_list_size=5end

Basic Example

address=AddressValidator::Address.new(name: 'Yum',street1: '33 St. Marks Place',city: 'New York',state: 'NY',zip: '10003',country: 'US')validator=AddressValidator::Validator.newresponse=validator.validate(address)# check if address is validresponse.valid?# get the returned addressnew_address=response.address# check if its a housenew_address.residential?

You can also pass hashes directly into the validator if you want.

validator=AddressValidator::Validator.newresponse=validator.validate(name: 'Yum',street1: '33 St. Marks Place',city: 'New York',state: 'NY',zip: '10003',country: 'US')# check if address is validresponse.valid?

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

Simple UPS address validation gem.

Resources

Stars

16 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages