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

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

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 Bates also did the following screencast on this gem:

http://railscasts.com/episodes/273-geocoder

Good luck,

-Conrad

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

Colin

Thanks Conrad

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

Here are some more options:

http://www.zipcodedownload.com/Products/Family/ZIP5/

Also, the above site has additional options.

Good luck,

-Conrad

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

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 Bates also did the following screencast on this gem:

http://railscasts.com/episodes/273-geocoder

Good luck,

-Conrad

USPS also has an API you can use.

I said zipcodes though, Colin.

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.

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

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