Class UtilValidate


  • public final class UtilValidate
    extends java.lang.Object
    General input/data validation methods Utility methods for validating data, especially input. See detailed description below.
    SUMMARY

    This is a set of meethods for validating input. Functions are provided to validate:
    - U.S. and international phone/fax numbers
    - U.S. ZIP codes(5 or 9 digit postal codes)
    - U.S. Postal Codes(2 letter abbreviations for names of states)
    - U.S. Social Security Numbers(abbreviated as SSNs)
    - email addresses
    - dates(entry of year, month, and day and validity of combined date)
    - credit card numbers

    Supporting utility functions validate that:
    - characters are Letter, Digit, or LetterOrDigit
    - strings are a Signed, Positive, Negative, Nonpositive, or Nonnegative integer
    - strings are a Float or a SignedFloat
    - strings are Alphabetic, Alphanumeric, or Whitespace
    - strings contain an integer within a specified range

    Other utility functions are provided to:
    - remove from a string characters which are/are not in a "bag" of selected characters
    - strip whitespace/leading whitespace from a string

    ==============================================================================
    NOTE: This code was adapted from the Netscape JavaScript form validation code,
    usually found in "FormChek.js". Credit card verification functions Originally
    included as Starter Application 1.0.0 in LivePayment.
    ==============================================================================
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String appendCheckDigit​(java.lang.String stPassed)  
      static java.lang.String checkValidDatabaseId​(java.lang.String fieldStr)  
      static int daysInFebruary​(int year)
      Given integer argument year, returns number of days in February of that year.
      static java.lang.String getCardType​(java.lang.String ccPassed)
      Checks to see if the cc number is a valid number for any accepted credit card, and return the name of that type
      static int getLuhnCheckDigit​(java.lang.String stPassed)  
      static int getLuhnSum​(java.lang.String stPassed)  
      static boolean isAlphabetic​(java.lang.String s)
      Returns true if string s is letters only.
      static boolean isAlphanumeric​(java.lang.String s)
      Returns true if string s is English letters (A ..
      static boolean isAmericanExpress​(java.lang.String cc)
      Checks to see if the cc number is a valid American Express number
      static boolean isAnyCard​(java.lang.String ccPassed)
      Checks to see if the cc number is a valid number for any accepted credit card
      static boolean isCardMatch​(java.lang.String cardType, java.lang.String cardNumberPassed)
      Checks to see if the cc number is a valid number for the specified type
      static boolean isCarteBlanche​(java.lang.String cc)
      Checks to see if the cc number is a valid Carte Blanche number
      static boolean isContiguousStateCode​(java.lang.String s)
      Return true if s is a valid contiguous U.S.
      static boolean isContiguousZipCode​(java.lang.String s)
      Returns true if string s is a valid contiguous U.S.
      static boolean isCreditCard​(java.lang.String stPassed)
      Checks credit card number with Luhn Mod-10 test
      static boolean isDate​(java.lang.String date)
      isDate returns true if string argument date forms a valid date.
      static boolean isDate​(java.lang.String year, java.lang.String month, java.lang.String day)
      isDate returns true if string arguments year, month, and day form a valid date.
      static boolean isDateAfterNow​(java.sql.Timestamp date)  
      static boolean isDateAfterToday​(java.lang.String date)
      isDate returns true if string argument date forms a valid date and is after today.
      static boolean isDateBeforeNow​(java.sql.Timestamp date)  
      static boolean isDateBeforeToday​(java.lang.String date)
      isDate returns true if string argument date forms a valid date and is before today.
      static boolean isDay​(java.lang.String s)
      isDay returns true if string s is a valid day number between 1 and 31.
      static boolean isDinersClub​(java.lang.String cc)
      Checks to see if the cc number is a valid Diners Club number
      static boolean isDiscover​(java.lang.String cc)
      Checks to see if the cc number is a valid Discover number
      static boolean isDouble​(java.lang.String s, boolean allowNegative, boolean allowPositive, int minDecimal, int maxDecimal)
      General routine for testing whether a string is a double.
      static boolean isEmail​(java.lang.String s)  
      static boolean isEmailList​(java.lang.String s)
      Checks a String for a valid Email-List seperated by ",".
      static boolean isEmpty​(java.lang.CharSequence c)
      Check whether charsequence c is empty.
      static boolean isEmpty​(java.lang.Object o)
      Check whether an object is empty, will see if it is a String, Map, Collection, etc.
      static <E> boolean isEmpty​(java.util.Collection<E> c)
      Check whether collection c is empty.
      static <K,​E>
      boolean
      isEmpty​(java.util.Map<K,​E> m)
      Check whether map m is empty.
      static boolean isEmpty​(IsEmpty o)
      Check whether IsEmpty o is empty.
      static boolean isEnRoute​(java.lang.String cc)
      Checks to see if the cc number is a valid EnRoute number
      static boolean isFloat​(java.lang.String s)
      True if string s is an unsigned floating point(real) number.
      static boolean isFloat​(java.lang.String s, boolean allowNegative, boolean allowPositive, int minDecimal, int maxDecimal)
      General routine for testing whether a string is a float.
      static boolean isGiftCard​(java.lang.String stPassed)
      Check to see if a card number is a supported Gift Card
      static boolean isHour​(java.lang.String s)
      isHour returns true if string s is a valid number between 0 and 23.
      static boolean isInteger​(java.lang.String s)
      Returns true if all characters in string s are numbers.
      static boolean isIntegerInRange​(java.lang.String s, int a, int b)
      isIntegerInRange returns true if string s is an integer within the range of integer arguments a and b, inclusive.
      static boolean isJCB​(java.lang.String cc)
      Checks to see if the cc number is a valid JCB number
      static boolean isMasterCard​(java.lang.String cc)
      Checks to see if the cc number is a valid Master Card number
      static boolean isMinute​(java.lang.String s)
      isMinute returns true if string s is a valid number between 0 and 59.
      static boolean isMonth​(java.lang.String s)
      isMonth returns true if string s is a valid month number between 1 and 12.
      static boolean isNegativeInteger​(java.lang.String s)
      Returns true if string s is an integer < 0
      static boolean isNonnegativeInteger​(java.lang.String s)
      Returns true if string s is an integer >= 0
      static boolean isNonpositiveInteger​(java.lang.String s)
      Returns true if string s is an integer <= 0
      static boolean isNotEmpty​(java.lang.CharSequence c)
      Check whether charsequence c is NOT empty.
      static boolean isNotEmpty​(java.lang.Object o)
      Check whether an object is NOT empty, will see if it is a String, Map, Collection, etc.
      static <E> boolean isNotEmpty​(java.util.Collection<E> c)
      Check whether collection c is NOT empty.
      static boolean isNotEmpty​(IsEmpty o)
      Check whether IsEmpty o is NOT empty.
      static boolean isOFBGiftCard​(java.lang.String stPassed)
      Check to see if a card number is a valid OFB Gift Card (Certifiicate)
      static boolean isPositiveInteger​(java.lang.String s)
      Returns true if string s is an integer > 0.
      static boolean isSecond​(java.lang.String s)
      isSecond returns true if string s is a valid number between 0 and 59.
      static boolean isSignedDouble​(java.lang.String s)
      True if string s is a signed or unsigned floating point (real) number.
      static boolean isSignedFloat​(java.lang.String s)
      True if string s is a signed or unsigned floating point (real) number.
      static boolean isSignedLong​(java.lang.String s)
      Returns true if all characters are numbers; first character is allowed to be + or - as well.
      static boolean isSSN​(java.lang.String s)
      isSSN returns true if string s is a valid U.S.
      static boolean isStateCode​(java.lang.String s)
      Return true if s is a valid U.S.
      static boolean isString​(java.lang.Object obj)  
      static boolean isSwitch​(java.lang.String cc)
      Checks to see if the cc number is a valid Switch number
      static boolean isTime​(java.lang.String time)
      isTime returns true if string argument time forms a valid time.
      static boolean isTime​(java.lang.String hour, java.lang.String minute, java.lang.String second)
      isTime returns true if string arguments hour, minute, and second form a valid time.
      static boolean isUrl​(java.lang.String s)
      isUrl returns true if the string contains ://
      static boolean isValidDatabaseId​(java.lang.String fieldStr, java.lang.StringBuffer errorDetails)  
      static boolean isValidPhoneNumber​(java.lang.String phoneNumber, Delegator delegator)  
      static boolean isValidUrl​(java.lang.String s)
      isValidUrl returns true if the string is a valid URL (using Commons UrlValidator)
      static boolean isValueLinkCard​(java.lang.String stPassed)
      Check to see if a card number is a valid ValueLink Gift Card
      static boolean isVisa​(java.lang.String cc)
      Checks to see if the cc number is a valid Visa number
      static boolean isWhitespace​(java.lang.String s)
      Returns true if string s is empty or whitespace characters only.
      static boolean isYear​(java.lang.String s)
      isYear returns true if string s is a valid Year number.
      static boolean isZipCode​(java.lang.String s)
      isZIPCode returns true if string s is a valid U.S.
      static java.lang.String stripCharsInBag​(java.lang.String s, java.lang.String bag)
      Removes all characters which appear in string bag from string s.
      static boolean sumIsMod10​(int sum)  
      static boolean urlInString​(java.lang.String s)
      urlInString returns true if the string contains :// and not "component://"
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOWER_CASE_LETTERS

        public static final java.lang.String LOWER_CASE_LETTERS
        lower-case letter characters
        See Also:
        Constant Field Values
      • UPPER_CASE_LETTERS

        public static final java.lang.String UPPER_CASE_LETTERS
        upper-case letter characters
        See Also:
        Constant Field Values
      • LETTERS

        public static final java.lang.String LETTERS
        letter characters
        See Also:
        Constant Field Values
      • DECIMAL_POINT_DELIMITER

        public static final java.lang.String DECIMAL_POINT_DELIMITER
        decimal point character differs by language and culture
        See Also:
        Constant Field Values
      • PHONE_NUMBER_DELIMITERS

        public static final java.lang.String PHONE_NUMBER_DELIMITERS
        non-digit characters which are allowed in phone numbers
        See Also:
        Constant Field Values
      • VALID_US_PHONE_CHARS

        public static final java.lang.String VALID_US_PHONE_CHARS
        characters which are allowed in US phone numbers
        See Also:
        Constant Field Values
      • VALID_WORLD_PHONE_CHARS

        public static final java.lang.String VALID_WORLD_PHONE_CHARS
        characters which are allowed in international phone numbers(a leading + is OK)
        See Also:
        Constant Field Values
      • SSN_DELIMITERS

        public static final java.lang.String SSN_DELIMITERS
        non-digit characters which are allowed in Social Security Numbers
        See Also:
        Constant Field Values
      • VALID_SSN_CHARS

        public static final java.lang.String VALID_SSN_CHARS
        characters which are allowed in Social Security Numbers
        See Also:
        Constant Field Values
      • DIGITS_IN_SSN

        public static final int DIGITS_IN_SSN
        U.S. Social Security Numbers have 9 DIGITS. They are formatted as 123-45-6789.
        See Also:
        Constant Field Values
      • DIGITS_IN_US_PHONE

        public static final int DIGITS_IN_US_PHONE
        U.S. phone numbers have 10 DIGITS. They are formatted as 123 456 7890 or(123) 456-7890.
        See Also:
        Constant Field Values
      • DIGITS_IN_US_PHONE_AREA

        public static final int DIGITS_IN_US_PHONE_AREA
        See Also:
        Constant Field Values
      • DIGITS_IN_US_PHONE_MAIN

        public static final int DIGITS_IN_US_PHONE_MAIN
        See Also:
        Constant Field Values
      • ZIP_CODE_DELIMITERS

        public static final java.lang.String ZIP_CODE_DELIMITERS
        non-digit characters which are allowed in ZIP Codes
        See Also:
        Constant Field Values
      • ZIP_CODE_DELIMITER

        public static final java.lang.String ZIP_CODE_DELIMITER
        our preferred delimiter for reformatting ZIP Codes
        See Also:
        Constant Field Values
      • VALID_ZIP_CODE_CHARS

        public static final java.lang.String VALID_ZIP_CODE_CHARS
        characters which are allowed in Social Security Numbers
        See Also:
        Constant Field Values
      • DIGITS_IN_ZIP_CODE_1

        public static final int DIGITS_IN_ZIP_CODE_1
        U.S. ZIP codes have 5 or 9 digits. They are formatted as 12345 or 12345-6789.
        See Also:
        Constant Field Values
      • DIGITS_IN_ZIP_CODE_2

        public static final int DIGITS_IN_ZIP_CODE_2
        U.S. ZIP codes have 5 or 9 digits. They are formatted as 12345 or 12345-6789.
        See Also:
        Constant Field Values
      • CREDIT_CARD_DELIMITERS

        public static final java.lang.String CREDIT_CARD_DELIMITERS
        non-digit characters which are allowed in credit card numbers
        See Also:
        Constant Field Values
      • US_STATE_CODE_DELIMITER

        public static final java.lang.String US_STATE_CODE_DELIMITER
        Delimiter for USStateCodes String
        See Also:
        Constant Field Values
      • US_STATE_CODES

        public static final java.lang.String US_STATE_CODES
        Valid U.S. Postal Codes for states, territories, armed forces, etc. See http://www.usps.gov/ncsc/lookups/abbr_state.txt.
        See Also:
        Constant Field Values
      • CONTIGUOUS_US_STATE_CODES

        public static final java.lang.String CONTIGUOUS_US_STATE_CODES
        Valid contiguous U.S. postal codes
        See Also:
        Constant Field Values
    • Method Detail

      • isEmpty

        public static boolean isEmpty​(java.lang.Object o)
        Check whether an object is empty, will see if it is a String, Map, Collection, etc.
      • isNotEmpty

        public static boolean isNotEmpty​(java.lang.Object o)
        Check whether an object is NOT empty, will see if it is a String, Map, Collection, etc.
      • isEmpty

        public static boolean isEmpty​(IsEmpty o)
        Check whether IsEmpty o is empty.
      • isNotEmpty

        public static boolean isNotEmpty​(IsEmpty o)
        Check whether IsEmpty o is NOT empty.
      • isEmpty

        public static <E> boolean isEmpty​(java.util.Collection<E> c)
        Check whether collection c is empty.
      • isEmpty

        public static <K,​E> boolean isEmpty​(java.util.Map<K,​E> m)
        Check whether map m is empty.
      • isEmpty

        public static boolean isEmpty​(java.lang.CharSequence c)
        Check whether charsequence c is empty.
      • isNotEmpty

        public static <E> boolean isNotEmpty​(java.util.Collection<E> c)
        Check whether collection c is NOT empty.
      • isNotEmpty

        public static boolean isNotEmpty​(java.lang.CharSequence c)
        Check whether charsequence c is NOT empty.
      • isString

        public static boolean isString​(java.lang.Object obj)
      • isWhitespace

        public static boolean isWhitespace​(java.lang.String s)
        Returns true if string s is empty or whitespace characters only.
      • stripCharsInBag

        public static java.lang.String stripCharsInBag​(java.lang.String s,
                                                       java.lang.String bag)
        Removes all characters which appear in string bag from string s.
      • isInteger

        public static boolean isInteger​(java.lang.String s)
        Returns true if all characters in string s are numbers. Accepts non-signed integers only. Does not accept floating point, exponential notation, etc.
      • isSignedLong

        public static boolean isSignedLong​(java.lang.String s)
        Returns true if all characters are numbers; first character is allowed to be + or - as well. Does not accept floating point, exponential notation, etc.
      • isPositiveInteger

        public static boolean isPositiveInteger​(java.lang.String s)
        Returns true if string s is an integer > 0. NOTE: using the Java Long object for greatest precision
      • isNonnegativeInteger

        public static boolean isNonnegativeInteger​(java.lang.String s)
        Returns true if string s is an integer >= 0
      • isNegativeInteger

        public static boolean isNegativeInteger​(java.lang.String s)
        Returns true if string s is an integer < 0
      • isNonpositiveInteger

        public static boolean isNonpositiveInteger​(java.lang.String s)
        Returns true if string s is an integer <= 0
      • isFloat

        public static boolean isFloat​(java.lang.String s)
        True if string s is an unsigned floating point(real) number. Also returns true for unsigned integers. If you wish to distinguish between integers and floating point numbers, first call isInteger, then call isFloat. Does not accept exponential notation.
      • isFloat

        public static boolean isFloat​(java.lang.String s,
                                      boolean allowNegative,
                                      boolean allowPositive,
                                      int minDecimal,
                                      int maxDecimal)
        General routine for testing whether a string is a float.
      • isDouble

        public static boolean isDouble​(java.lang.String s,
                                       boolean allowNegative,
                                       boolean allowPositive,
                                       int minDecimal,
                                       int maxDecimal)
        General routine for testing whether a string is a double.
      • isSignedFloat

        public static boolean isSignedFloat​(java.lang.String s)
        True if string s is a signed or unsigned floating point (real) number. First character is allowed to be + or -. Also returns true for unsigned integers. If you wish to distinguish between integers and floating point numbers, first call isSignedInteger, then call isSignedFloat.
      • isSignedDouble

        public static boolean isSignedDouble​(java.lang.String s)
        True if string s is a signed or unsigned floating point (real) number. First character is allowed to be + or -. Also returns true for unsigned integers. If you wish to distinguish between integers and floating point numbers, first call isSignedInteger, then call isSignedFloat.
      • isAlphabetic

        public static boolean isAlphabetic​(java.lang.String s)
        Returns true if string s is letters only. NOTE: This should handle i18n version to support European characters, etc. since it now uses Character.isLetter()
      • isAlphanumeric

        public static boolean isAlphanumeric​(java.lang.String s)
        Returns true if string s is English letters (A .. Z, a..z) and numbers only. NOTE: Need i18n version to support European characters. This could be tricky due to different character sets and orderings for various languages and platforms.
      • isSSN

        public static boolean isSSN​(java.lang.String s)
        isSSN returns true if string s is a valid U.S. Social Security Number. Must be 9 digits.
      • isZipCode

        public static boolean isZipCode​(java.lang.String s)
        isZIPCode returns true if string s is a valid U.S. ZIP code. Must be 5 or 9 digits only.
      • isContiguousZipCode

        public static boolean isContiguousZipCode​(java.lang.String s)
        Returns true if string s is a valid contiguous U.S. Zip code. Must be 5 or 9 digits only.
      • isStateCode

        public static boolean isStateCode​(java.lang.String s)
        Return true if s is a valid U.S. Postal Code (abbreviation for state).
      • isContiguousStateCode

        public static boolean isContiguousStateCode​(java.lang.String s)
        Return true if s is a valid contiguous U.S. Postal Code (abbreviation for state).
      • isEmail

        public static boolean isEmail​(java.lang.String s)
      • isEmailList

        public static boolean isEmailList​(java.lang.String s)
        Checks a String for a valid Email-List seperated by ",".
      • isUrl

        public static boolean isUrl​(java.lang.String s)
        isUrl returns true if the string contains ://
        Parameters:
        s - String to validate Note: this does not handle "component://" specific to OFBiz
        Returns:
        true if s contains ://
      • urlInString

        public static boolean urlInString​(java.lang.String s)
        urlInString returns true if the string contains :// and not "component://"
        Parameters:
        s - String to validate
        Returns:
        true if s contains :// and not "component://"
      • isValidUrl

        public static boolean isValidUrl​(java.lang.String s)
        isValidUrl returns true if the string is a valid URL (using Commons UrlValidator)
        Parameters:
        s - String to validate
        Returns:
        true if s contains if the string is a valid URL (using Commons UrlValidator)
      • isYear

        public static boolean isYear​(java.lang.String s)
        isYear returns true if string s is a valid Year number. Must be 2 or 4 digits only. For Year 2000 compliance, you are advised to use 4-digit year numbers everywhere.
      • isIntegerInRange

        public static boolean isIntegerInRange​(java.lang.String s,
                                               int a,
                                               int b)
        isIntegerInRange returns true if string s is an integer within the range of integer arguments a and b, inclusive.
      • isMonth

        public static boolean isMonth​(java.lang.String s)
        isMonth returns true if string s is a valid month number between 1 and 12.
      • isDay

        public static boolean isDay​(java.lang.String s)
        isDay returns true if string s is a valid day number between 1 and 31.
      • daysInFebruary

        public static int daysInFebruary​(int year)
        Given integer argument year, returns number of days in February of that year.
      • isHour

        public static boolean isHour​(java.lang.String s)
        isHour returns true if string s is a valid number between 0 and 23.
      • isMinute

        public static boolean isMinute​(java.lang.String s)
        isMinute returns true if string s is a valid number between 0 and 59.
      • isSecond

        public static boolean isSecond​(java.lang.String s)
        isSecond returns true if string s is a valid number between 0 and 59.
      • isDate

        public static boolean isDate​(java.lang.String year,
                                     java.lang.String month,
                                     java.lang.String day)
        isDate returns true if string arguments year, month, and day form a valid date.
      • isDate

        public static boolean isDate​(java.lang.String date)
        isDate returns true if string argument date forms a valid date.
      • isDateAfterToday

        public static boolean isDateAfterToday​(java.lang.String date)
        isDate returns true if string argument date forms a valid date and is after today.
      • isDateBeforeToday

        public static boolean isDateBeforeToday​(java.lang.String date)
        isDate returns true if string argument date forms a valid date and is before today.
      • isDateBeforeNow

        public static boolean isDateBeforeNow​(java.sql.Timestamp date)
      • isDateAfterNow

        public static boolean isDateAfterNow​(java.sql.Timestamp date)
      • isTime

        public static boolean isTime​(java.lang.String hour,
                                     java.lang.String minute,
                                     java.lang.String second)
        isTime returns true if string arguments hour, minute, and second form a valid time.
      • isTime

        public static boolean isTime​(java.lang.String time)
        isTime returns true if string argument time forms a valid time.
      • isValueLinkCard

        public static boolean isValueLinkCard​(java.lang.String stPassed)
        Check to see if a card number is a valid ValueLink Gift Card
        Parameters:
        stPassed - a string representing a valuelink gift card
        Returns:
        true, if the number passed simple checks
      • isOFBGiftCard

        public static boolean isOFBGiftCard​(java.lang.String stPassed)
        Check to see if a card number is a valid OFB Gift Card (Certifiicate)
        Parameters:
        stPassed - a string representing a gift card
        Returns:
        tru, if the number passed simple checks
      • isGiftCard

        public static boolean isGiftCard​(java.lang.String stPassed)
        Check to see if a card number is a supported Gift Card
        Parameters:
        stPassed - a string representing a gift card
        Returns:
        true, if the number passed simple checks
      • getLuhnSum

        public static int getLuhnSum​(java.lang.String stPassed)
      • getLuhnCheckDigit

        public static int getLuhnCheckDigit​(java.lang.String stPassed)
      • sumIsMod10

        public static boolean sumIsMod10​(int sum)
      • appendCheckDigit

        public static java.lang.String appendCheckDigit​(java.lang.String stPassed)
      • isCreditCard

        public static boolean isCreditCard​(java.lang.String stPassed)
        Checks credit card number with Luhn Mod-10 test
        Parameters:
        stPassed - a string representing a credit card number
        Returns:
        true, if the credit card number passes the Luhn Mod-10 test, false otherwise
      • isVisa

        public static boolean isVisa​(java.lang.String cc)
        Checks to see if the cc number is a valid Visa number
        Parameters:
        cc - a string representing a credit card number; Sample number: 4111 1111 1111 1111(16 digits)
        Returns:
        true, if the credit card number is a valid VISA number, false otherwise
      • isMasterCard

        public static boolean isMasterCard​(java.lang.String cc)
        Checks to see if the cc number is a valid Master Card number
        Parameters:
        cc - a string representing a credit card number; MasterCard numbers either start with the numbers 51 through 55 or with the numbers 2221 through 2720. All have 16 digits; Sample number: 5500 0000 0000 0004(16 digits)
        Returns:
        true, if the credit card number is a valid MasterCard number, false otherwise
      • isAmericanExpress

        public static boolean isAmericanExpress​(java.lang.String cc)
        Checks to see if the cc number is a valid American Express number
        Parameters:
        cc - - a string representing a credit card number; Sample number: 340000000000009(15 digits)
        Returns:
        true, if the credit card number is a valid American Express number, false otherwise
      • isDinersClub

        public static boolean isDinersClub​(java.lang.String cc)
        Checks to see if the cc number is a valid Diners Club number
        Parameters:
        cc - - a string representing a credit card number; Sample number: 30000000000004(14 digits)
        Returns:
        true, if the credit card number is a valid Diner's Club number, false otherwise
      • isCarteBlanche

        public static boolean isCarteBlanche​(java.lang.String cc)
        Checks to see if the cc number is a valid Carte Blanche number
        Parameters:
        cc - - a string representing a credit card number; Sample number: 30000000000004(14 digits)
        Returns:
        true, if the credit card number is a valid Carte Blanche number, false otherwise
      • isDiscover

        public static boolean isDiscover​(java.lang.String cc)
        Checks to see if the cc number is a valid Discover number
        Parameters:
        cc - - a string representing a credit card number; Discover card numbers begin with 6011 or 65. All have 16 digits; Sample number: 6011000000000004(16 digits)
        Returns:
        true, if the credit card number is a valid Discover card number, false otherwise
      • isEnRoute

        public static boolean isEnRoute​(java.lang.String cc)
        Checks to see if the cc number is a valid EnRoute number
        Parameters:
        cc - - a string representing a credit card number; Sample number: 201400000000009(15 digits)
        Returns:
        true, if the credit card number is a valid enRoute card number, false, otherwise
      • isJCB

        public static boolean isJCB​(java.lang.String cc)
        Checks to see if the cc number is a valid JCB number
        Parameters:
        cc - - a string representing a credit card number; JCB cards beginning with 2131 or 1800 have 15 digits. JCB cards beginning with 35 have 16 digits;Sample number: 3088000000000009(16 digits)
        Returns:
        true, if the credit card number is a valid JCB card number, false otherwise
      • isSwitch

        public static boolean isSwitch​(java.lang.String cc)
        Checks to see if the cc number is a valid Switch number
        Parameters:
        cc - - a string representing a credit card number; Sample number: 6331100000000096(16 digits)
        Returns:
        true, if the credit card number is a valid Switch card number, false otherwise
      • isAnyCard

        public static boolean isAnyCard​(java.lang.String ccPassed)
        Checks to see if the cc number is a valid number for any accepted credit card
        Parameters:
        ccPassed - - a string representing a credit card number
        Returns:
        true, if the credit card number is any valid credit card number for any of the accepted card types, false otherwise
      • getCardType

        public static java.lang.String getCardType​(java.lang.String ccPassed)
        Checks to see if the cc number is a valid number for any accepted credit card, and return the name of that type
        Parameters:
        ccPassed - - a string representing a credit card number
        Returns:
        true, if the credit card number is any valid credit card number for any of the accepted card types, false otherwise
      • isCardMatch

        public static boolean isCardMatch​(java.lang.String cardType,
                                          java.lang.String cardNumberPassed)
        Checks to see if the cc number is a valid number for the specified type
        Parameters:
        cardType - - a string representing the credit card type
        cardNumberPassed - - a string representing a credit card number
        Returns:
        true, if the credit card number is valid for the particular credit card type given in "cardType", false otherwise
      • checkValidDatabaseId

        public static java.lang.String checkValidDatabaseId​(java.lang.String fieldStr)
      • isValidDatabaseId

        public static boolean isValidDatabaseId​(java.lang.String fieldStr,
                                                java.lang.StringBuffer errorDetails)
      • isValidPhoneNumber

        public static boolean isValidPhoneNumber​(java.lang.String phoneNumber,
                                                 Delegator delegator)