@Test public void testIsStateReturnsTrueForAllStateAbbreviations() throws Exception { String[] states = ("AL|AK|AS|AZ|AR|CA|CO|CT|DE|DC|FM|FL|FA|GU|HI|ID|IL|IN|IA|KS|KY|LA|ME|MH|MD|" + "MA|MI|MN|MS|MO|MT|NE|NV|NH|NJ|NM|NY|NC|ND|MP|OH|OK|OR|PW|PA|PR|RI|SC|SD|TN|TX|" + "UT|VT|VI|VA|WA|WV|WI|WY").split("\\|"); for (String state : states) { assertTrue(StringValidations.isState(state)); } }
public static boolean isState(final String state) { if (state != null) { return state.toUpperCase().matches( "^(AL|AK|AS|AZ|AR|CA|CO|CT|DE|DC|FM|FL|FA|GU|HI|ID|IL|IN|IA|KS|KY|LA|ME|MH|MD|" + "MA|MI|MN|MS|MO|MT|NE|NV|NH|NJ|NM|NY|NC|ND|MP|OH|OK|OR|PW|PA|PR|RI|SC|SD|TN|TX|" + "UT|VT|VI|VA|WA|WV|WI|WY)$"); } return false; }
StringValidations { public static boolean isState(final String state) { if (state != null) { return state.toUpperCase().matches( "^(AL|AK|AS|AZ|AR|CA|CO|CT|DE|DC|FM|FL|FA|GU|HI|ID|IL|IN|IA|KS|KY|LA|ME|MH|MD|" + "MA|MI|MN|MS|MO|MT|NE|NV|NH|NJ|NM|NY|NC|ND|MP|OH|OK|OR|PW|PA|PR|RI|SC|SD|TN|TX|" + "UT|VT|VI|VA|WA|WV|WI|WY)$"); } return false; } }
StringValidations { public static boolean isState(final String state) { if (state != null) { return state.toUpperCase().matches( "^(AL|AK|AS|AZ|AR|CA|CO|CT|DE|DC|FM|FL|FA|GU|HI|ID|IL|IN|IA|KS|KY|LA|ME|MH|MD|" + "MA|MI|MN|MS|MO|MT|NE|NV|NH|NJ|NM|NY|NC|ND|MP|OH|OK|OR|PW|PA|PR|RI|SC|SD|TN|TX|" + "UT|VT|VI|VA|WA|WV|WI|WY)$"); } return false; }  }
StringValidations { public static boolean isState(final String state) { if (state != null) { return state.toUpperCase().matches( "^(AL|AK|AS|AZ|AR|CA|CO|CT|DE|DC|FM|FL|FA|GU|HI|ID|IL|IN|IA|KS|KY|LA|ME|MH|MD|" + "MA|MI|MN|MS|MO|MT|NE|NV|NH|NJ|NM|NY|NC|ND|MP|OH|OK|OR|PW|PA|PR|RI|SC|SD|TN|TX|" + "UT|VT|VI|VA|WA|WV|WI|WY)$"); } return false; }  static boolean isAlphabetic(final String text); static boolean isAlphanumeric(final String textWithDigits); static boolean isAlphanumericDash(String text); static boolean isAlphanumericSpaceUnderscore(final String textWithDigits); static boolean isEmptyString(final String text); static boolean isPunctuatedText(final String text); static boolean isPunctuatedTextWithoutSpace(final String text); static boolean isDecimal(final String number); static boolean isWholeNumber(final String number); static boolean isDigit(final String digit); static boolean isEmailAddress(final String email); static boolean isState(final String state); static boolean isZipCode(final String zipCode); static boolean isPhoneNumber(final String phoneNumber); static boolean isPassword(final String password); static boolean isStrictPassword(final String password); static boolean hasData(final String value); static boolean length(final int length, final String value); static boolean minLength(final int length, final String value); static boolean maxLength(final int length, final String value); }
StringValidations { public static boolean isState(final String state) { if (state != null) { return state.toUpperCase().matches( "^(AL|AK|AS|AZ|AR|CA|CO|CT|DE|DC|FM|FL|FA|GU|HI|ID|IL|IN|IA|KS|KY|LA|ME|MH|MD|" + "MA|MI|MN|MS|MO|MT|NE|NV|NH|NJ|NM|NY|NC|ND|MP|OH|OK|OR|PW|PA|PR|RI|SC|SD|TN|TX|" + "UT|VT|VI|VA|WA|WV|WI|WY)$"); } return false; }  static boolean isAlphabetic(final String text); static boolean isAlphanumeric(final String textWithDigits); static boolean isAlphanumericDash(String text); static boolean isAlphanumericSpaceUnderscore(final String textWithDigits); static boolean isEmptyString(final String text); static boolean isPunctuatedText(final String text); static boolean isPunctuatedTextWithoutSpace(final String text); static boolean isDecimal(final String number); static boolean isWholeNumber(final String number); static boolean isDigit(final String digit); static boolean isEmailAddress(final String email); static boolean isState(final String state); static boolean isZipCode(final String zipCode); static boolean isPhoneNumber(final String phoneNumber); static boolean isPassword(final String password); static boolean isStrictPassword(final String password); static boolean hasData(final String value); static boolean length(final int length, final String value); static boolean minLength(final int length, final String value); static boolean maxLength(final int length, final String value); static final String EMAIL_REGEX; }