[Patch] added functions for Validate_US + tests
| From: | Matt | Date: | Mon, 28 Jun 2004 15:24:16 +0000 |
| Subject: | [Patch] added functions for Validate_US + tests | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-31304@lists.php.net to get a copy of this message | ||
I'm using three functions I've added to Validate_US, for validating ZIP codes, phone numbers and two-digit state abbreviations.
ZIPcode() allows five digit or nine digit ZIPs, but can be told to only allow five digit ZIPs. It allows nine-digit entries without a dash. Valid ZIPs do not seem to require a dash (from what I could find on usps.gov). Does anyone know or have an opinion on that?
PhoneNumber() is a fairly liberal about format and it can be told to force an area code to be included (10 digits). As far as formatting it allows parentheses around the area code or not and it allows a space, dash or nothing between digits 3-4 and 6-7. Maybe this should have a parameter that describes the formatting it accepts?
State() has a list of the valid two-digit codes for the 50 US states. It is also possible to allow inclusion of Washington, DC. Maybe this should be renamed TwoDigitState() and either include US territories or create another function to validate US territories.
also attached are the tests that I wrote for these functions "validate_US.php".
Comments would be helpful,
thanks,
matt
--
Disclaimer: This message (including any attachments) contains
confidential information intended for a specific individual and purpose,
and is protected by law. If you are not the intended recipient, you
should delete this message. Any disclosure, copying, or distribution of
this message, or the taking of any action based on it, is strictly
prohibited.