MCPcopy Create free account
hub / github.com/banq/jdonframework / isZipCode

Method isZipCode

src/main/java/com/jdon/util/UtilValidate.java:607–613  ·  view source on GitHub ↗

isZIPCode returns true if string s is a valid U.S. ZIP code. Must be 5 or 9 digits only.

(String s)

Source from the content-addressed store, hash-verified

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) {

Callers 1

isContiguousZipCodeMethod · 0.95

Calls 3

isEmptyMethod · 0.95
stripCharsInBagMethod · 0.95
isIntegerMethod · 0.95

Tested by

no test coverage detected