Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #10677
| From | Fiver <numeralfive@gmail.com> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: Zip Codes ctype? Pregmatch? |
| Date | 2013-08-31 16:40 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <kvsv93$t5r$1@dont-email.me> (permalink) |
| References | <kv08v0$614$1@speranza.aioe.org> <jb-dnQwr1JgOF7zPnZ2dnUVZ_oSdnZ2d@posted.internetamerica> |
On 2013-08-31 08:17, Gordon Burditt wrote: >> I'm attempting to check for US and Canadian zip codes (postal codes). > > For what purpose? The reason I ask is that the type of checking you > do may depend on the reason for the checking. > > What do you want to do with the (US) ZIP code? [..snip..] > If your requirement is to check because you want to check, you don't > care WHAT you check, you just wanna check! You WANNA! You WANNA! > You WANNA! then I have to wonder if the whole project should be > dropped. If he had no reason to collect the postal codes at all, he wouldn't have put them in the form (I hope). As soon as he does collect and store them somewhere (like a database), for whatever purpose, he needs to do some basic formal/plausibility checking. This would be true even if he didn't limit the input to US and Canadian codes. There are some general assumptions you can make about postal codes that are valid everywhere in the world. For example - no valid code will start/end with white space - codes will never be longer than 20 characters - codes without any alphanumeric characters are never valid This is just basic data hygiene. I would never store user input without at least checking the known formal constraints of the field. The more he knows about the codes, the more he can check. This is where the formal validation for the US/Canadian codes comes in. The general format is known. If he has this information, he should use it, if only to prevent some categories of typos. Checking if a postal code is actually assigned to a real location at this point in time, or if a certain delivery method is available to the location - that's well outside the area of formal checks. If this level of validation is required, he'll need an API from the delivery service (or whoever is going to use the code). Then he needs to validate the code at least twice: once on entry and once before sending out an actual package. > The USA is easy. Rejecting 00000 and 99999 is simple, and you don't > worry about the other 57,998 or so codes that might get used in the > future. > > Unless you can find a general specification for Canadian Postal > codes, *NOT* what's currently in use, you're probably better off > allowing A-Z everywhere a letter is currently allowed. Good advice. > You might also exclude H0H 0H0, which is reserved for Santa Claus. Just wondering... why does Santa Claus have a Canadian postal code? The geographic north pole outside Canadian territory. If his house was as close to the north pole as he can get while still remaining on firm land, he should have a Danish postal code. regards, 5er
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Zip Codes ctype? Pregmatch? Twayne <nobody@spamcop.net> - 2013-08-20 13:27 -0400
Re: Zip Codes ctype? Pregmatch? Martin Leese <please@see.Web.for.e-mail.INVALID> - 2013-08-20 11:59 -0600
Re: Zip Codes ctype? Pregmatch? Twayne <nobody@spamcop.net> - 2013-08-20 15:01 -0400
Re: Zip Codes ctype? Pregmatch? Robert Heller <heller@deepsoft.com> - 2013-08-20 13:08 -0500
Re: Zip Codes ctype? Pregmatch? Twayne <nobody@spamcop.net> - 2013-08-20 15:03 -0400
Re: Zip Codes ctype? Pregmatch? Robert Heller <heller@deepsoft.com> - 2013-08-20 14:36 -0500
Re: Zip Codes ctype? Pregmatch? Twayne <nobody@spamcop.net> - 2013-08-20 20:17 -0400
Re: Zip Codes ctype? Pregmatch? RESOLVED Twayne <nobody@spamcop.net> - 2013-08-20 15:06 -0400
Re: Zip Codes ctype? Pregmatch? RESOLVED Norman Peelman <npeelman@cfl.rr.com> - 2013-08-20 19:53 -0400
Re: Zip Codes ctype? Pregmatch? RESOLVED Twayne <nobody@spamcop.net> - 2013-08-20 20:29 -0400
Re: Zip Codes ctype? Pregmatch? RESOLVED Moon Elf <moonelf@moonelfsystem.net> - 2013-12-16 10:02 +0000
Re: Zip Codes ctype? Pregmatch? RESOLVED Doug Miller <doug_at_milmac_dot_com@example.com> - 2013-12-16 12:27 +0000
Re: Zip Codes ctype? Pregmatch? Norman Peelman <npeelman@cfl.rr.com> - 2013-08-20 19:52 -0400
Re: Zip Codes ctype? Pregmatch? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-08-21 14:53 +0200
Re: Zip Codes ctype? Pregmatch? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-08-21 14:58 +0200
Re: Zip Codes ctype? Pregmatch? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-08-21 15:06 +0200
Re: Zip Codes ctype? Pregmatch? Curtis Dyer <dyer85@gmail.com> - 2013-08-24 10:22 +0000
Re: Zip Codes ctype? Pregmatch? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-08-24 12:52 +0200
Re: Zip Codes ctype? Pregmatch? Doug Miller <doug_at_milmac_dot_com@example.com> - 2013-08-25 14:31 +0000
Re: Zip Codes ctype? Pregmatch? Twayne <nobody@spamcop.net> - 2013-08-25 13:21 -0400
Re: Zip Codes ctype? Pregmatch? Twayne <nobody@spamcop.net> - 2013-08-25 13:17 -0400
Re: Zip Codes ctype? Pregmatch? Twayne <nobody@spamcop.net> - 2013-08-21 19:10 -0400
Re: Zip Codes ctype? Pregmatch? BootNic <bootnic.bounce@gmail.com> - 2013-08-21 22:09 -0400
Re: Zip Codes ctype? Pregmatch? Twayne <nobody@spamcop.net> - 2013-08-22 18:22 -0400
Re: Zip Codes ctype? Pregmatch? Jeff North <jnorthau@yahoo.com.au> - 2013-08-21 21:25 +1000
Re: Zip Codes ctype? Pregmatch? Twayne <nobody@spamcop.net> - 2013-08-21 18:53 -0400
Re: Zip Codes ctype? Pregmatch? Norman Peelman <npeelman@cfl.rr.com> - 2013-08-21 22:46 -0400
Re: Zip Codes ctype? Pregmatch? gordonb.qnlcm@burditt.org (Gordon Burditt) - 2013-08-31 01:17 -0500
Re: Zip Codes ctype? Pregmatch? Fiver <numeralfive@gmail.com> - 2013-08-31 16:40 +0200
Re: Zip Codes ctype? Pregmatch? Norman Peelman <npeelman@cfl.rr.com> - 2013-08-31 11:56 -0400
Re: Zip Codes ctype? Pregmatch? Welsh Vanner <welshvanners@welsh-vanners.co.uk> - 2013-08-31 20:23 +0100
Re: Zip Codes ctype? Pregmatch? Twayne <nobody@spamcop.net> - 2013-08-31 20:21 -0400
Re: Zip Codes ctype? Pregmatch? Martin Leese <please@see.Web.for.e-mail.INVALID> - 2013-08-31 09:56 -0600
Re: Zip Codes ctype? Pregmatch? Twayne <nobody@spamcop.net> - 2013-08-31 20:07 -0400
csiph-web