I'm a little unclear what you are asking, but I'll tell what I know. You just want to know if a 5 digit zip code is a valid one? Or do you want to compare it to the list of valid city names that are assigned to it? (yes it can be more than one, ugh)
They are (from a non-USPS point of view) arbitrarily assigned by the  
post office and there are currently 42,305 or so assigned (out of a  
theoretical maximum of 100,000 of course)
So assuming you just want to know if it's a valid zip (and don't care  
about if they got the city right), the only way to validate it solely  
from within your app as a valid zip code would be to have a list of  
them in your app.
You could load them from a plist or straight text I guess into an  
NSArray or NSSet and then check to see if the zip is valid as needed.
You can get the list from a third party service like http://www.zipcodeworld.com/ 
 or maybe from some free source.
The value of this might be questionable, since a zip code with a typo  
still has roughly a 50% chance of being a valid one. Plus the USPS is  
always adding new ones, so will you risk telling your user that his  
zip code doesn't exist when he is standing in it?
So I guess the answer is there is no Cocoa technology that can help  
with this--unless you are asking something completely different, in  
which case let's all have a good chuckle at my poor comprehension  
skills :)
On Jan 7, 2010, at 11:11 AM, Eric E. Dolecki wrote:

I've been googling but haven't seen yet how to best validate a 5-digit
zipcode for use in the US (without using a webservice).

I have the NSString, I just need to validate it. I know zero RegExp, is
there a formatter I can use?
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to