isZIPCode returns true if string s is a valid U.S. ZIP code. Must be 5 or 9 digits only.
(String s)
| 605 | |
| 606 | /** isZIPCode returns true if string s is a valid U.S. ZIP code. Must be 5 or 9 digits only. */ |
| 607 | public static boolean isZipCode(String s) { |
| 608 | if (isEmpty(s)) return defaultEmptyOK; |
| 609 | |
| 610 | String normalizedZip = stripCharsInBag(s, ZipCodeDelimiters); |
| 611 | |
| 612 | return (isInteger(normalizedZip) && ((normalizedZip.length() == digitsInZipCode1) || (normalizedZip.length() == digitsInZipCode2))); |
| 613 | } |
| 614 | |
| 615 | /** Returns true if string s is a valid contiguous U.S. Zip code. Must be 5 or 9 digits only. */ |
| 616 | public static boolean isContiguousZipCode(String s) { |
no test coverage detected