Validating for Real Zipcodes

Hi guys,

I have a location sensitive application where clients enter their
zipcodes when signing up. Is there any tool out there, or anyway to
confirm that the zipcode entered is indeed a true and valid zipcode
and not just 5 random numbers?

Thanks and Regards,
Bertly

On Fri, Jul 8, 2011 at 12:29 PM, bertly_the_coder [email protected]
wrote:

Bertly, you might want to take a look at Geocoder:

http://rubygems.org/gems/geocoder

If you provide and invalid zip code, then you should get nil. For
example,

$ irb
ruby-1.9.2-head :001 > require ‘geocoder’
=> true
ruby-1.9.2-head :002 > Geocoder.coordinates(“25 Main St, Cooperstown,
NY”)
=> [42.700124, -74.922749]
ruby-1.9.2-head :003 > Geocoder.coordinates(“90230”)
=> [33.9933257, -118.3987842]
ruby-1.9.2-head :004 > Geocoder.coordinates(“00000”)
=> nil

BTW, Ryan B. also did the following screencast on this gem:

Good luck,

-Conrad

Thanks Conrad

On 8 July 2011 20:29, bertly_the_coder [email protected] wrote:

Hi guys,

I have a location sensitive application where clients enter their
zipcodes when signing up. Is there any tool out there, or anyway to
confirm that the zipcode entered is indeed a true and valid zipcode
and not just 5 random numbers?

Postal codes are not always just 5 digits. In the UK they are a
combination of letters and digits for example.

Colin

On Fri, Jul 8, 2011 at 12:29 PM, bertly_the_coder [email protected]
wrote:

Here are some more options:

Also, the above site has additional options.

Good luck,

-Conrad

On Jul 8, 2011, at 1:29 PM, bertly_the_coder wrote:

I have a location sensitive application where clients enter their
zipcodes when signing up. Is there any tool out there, or anyway to
confirm that the zipcode entered is indeed a true and valid zipcode
and not just 5 random numbers?

That’s hard, because they’re updated fairly frequently according to USPS
needs, so a one-time file import would not be very good. Which leaves
you looking for a service to subscribe to.


Scott R.
[email protected]
http://www.elevated-dev.com/
(303) 722-0567 voice

On Fri, Jul 8, 2011 at 12:29 PM, bertly_the_coder [email protected]
wrote:

Bertly, if you’re within the US, the you might be able to use the
services
used by USPS located here:

http://www.usps.com/webtools/

I’m guessing using a service like this that the data will always be up
to
date. Also, it should gel nicely with Rails.

Good luck,

-Conrad

Sent from my iPhone

On Jul 8, 2011, at 12:52 PM, Conrad T. [email protected] wrote:

ruby-1.9.2-head :002 > Geocoder.coordinates(“25 Main St, Cooperstown, NY”)
Good luck,

-Conrad

USPS also has an API you can use.

I said zipcodes though, Colin.