Package org.apache.ofbiz.base.util
Class UtilValidate
- java.lang.Object
-
- org.apache.ofbiz.base.util.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.
==============================================================================
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ContiguousUSStateCodes
Valid contiguous U.S.static java.lang.String
creditCardDelimiters
non-digit characters which are allowed in credit card numbersstatic java.lang.String
decimalPointDelimiter
decimal point character differs by language and culturestatic java.lang.String
digits
digit charactersstatic int
digitsInSocialSecurityNumber
U.S.static int
digitsInUSPhoneAreaCode
static int
digitsInUSPhoneMainNumber
static int
digitsInUSPhoneNumber
U.S.static int
digitsInZipCode1
U.S.static int
digitsInZipCode2
U.S.static java.lang.String
letters
letter charactersstatic java.lang.String
lowercaseLetters
lower-case letter charactersstatic java.lang.String
module
static java.lang.String
phoneNumberDelimiters
non-digit characters which are allowed in phone numbersstatic java.lang.String
SSNDelimiters
non-digit characters which are allowed in Social Security Numbersstatic java.lang.String
uppercaseLetters
upper-case letter charactersstatic java.lang.String
USStateCodeDelimiter
Delimiter for USStateCodes Stringstatic java.lang.String
USStateCodes
Valid U.S.static java.lang.String
validSSNChars
characters which are allowed in Social Security Numbersstatic java.lang.String
validUSPhoneChars
characters which are allowed in US phone numbersstatic java.lang.String
validWorldPhoneChars
characters which are allowed in international phone numbers(a leading + is OK)static java.lang.String
validZipCodeChars
characters which are allowed in Social Security Numbersstatic java.lang.String
ZipCodeDelimeter
our preferred delimiter for reformatting ZIP Codesstatic java.lang.String
ZipCodeDelimiters
non-digit characters which are allowed in ZIP Codes
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
appendCheckDigit(java.lang.String stPassed)
static boolean
areEqual(java.lang.Object obj, java.lang.Object obj2)
static char
calcChecksum(java.lang.String value, int length)
static char
calcUpcChecksum(java.lang.String upc)
static boolean
charInString(char c, java.lang.String s)
Returns true if single character c(actually a string) is contained within string s.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 typestatic 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 numberstatic boolean
isAnyCard(java.lang.String ccPassed)
Checks to see if the cc number is a valid number for any accepted credit cardstatic boolean
isCardMatch(java.lang.String cardType, java.lang.String cardNumberPassed)
Checks to see if the cc number is a valid number for the specified typestatic boolean
isCarteBlanche(java.lang.String cc)
Checks to see if the cc number is a valid Carte Blanche numberstatic 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 teststatic 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
isDigit(char c)
Returns true if character c is a digit (0 ..static boolean
isDinersClub(java.lang.String cc)
Checks to see if the cc number is a valid Diners Club numberstatic boolean
isDiscover(java.lang.String cc)
Checks to see if the cc number is a valid Discover numberstatic 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>
booleanisEmpty(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 numberstatic 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 Cardstatic boolean
isHexDigit(char c)
Returns true if character c is a letter or digit.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 numberstatic boolean
isLetter(char c)
Returns true if character c is an English letter (A ..static boolean
isLetterOrDigit(char c)
Returns true if character c is a letter or digit.static boolean
isMasterCard(java.lang.String cc)
Checks to see if the cc number is a valid Master Card numberstatic 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 < 0static boolean
isNonnegativeInteger(java.lang.String s)
Returns true if string s is an integer >= 0static boolean
isNonpositiveInteger(java.lang.String s)
Returns true if string s is an integer <= 0static 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
isNotPoBox(java.lang.String s)
isNotPoBox returns true if address argument does not contain anything that looks like a a PO Box.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
isSignedInteger(java.lang.String s)
Returns true if all characters are numbers; first character is allowed to be + or - as well.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
isSolo(java.lang.String cc)
Checks to see if the cc number is a valid Solo numberstatic 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 numberstatic 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
isValidDatabaseId(java.lang.String fieldStr, java.lang.StringBuilder errorDetails)
static boolean
isValidEan(java.lang.String ean)
static boolean
isValidPhoneNumber(java.lang.String phoneNumber, java.lang.String geoId, Delegator delegator)
static boolean
isValidPhoneNumber(java.lang.String phoneNumber, Delegator delegator)
static boolean
isValidUpc(java.lang.String upc)
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 Cardstatic boolean
isVisa(java.lang.String cc)
Checks to see if the cc number is a valid Visa numberstatic boolean
isVisaElectron(java.lang.String cc)
Checks to see if the cc number is a valid Visa Electron numberstatic 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 java.lang.String
stripCharsNotInBag(java.lang.String s, java.lang.String bag)
Removes all characters which do NOT appear in string bag from string s.static java.lang.String
stripInitialWhitespace(java.lang.String s)
Removes initial(leading) whitespace characters from s.static java.lang.String
stripWhitespace(java.lang.String s)
Removes all whitespace characters from s.static boolean
sumIsMod10(int sum)
static boolean
urlInString(java.lang.String s)
urlInString returns true if the string contains :// and not "component://"
-
-
-
Field Detail
-
module
public static final java.lang.String module
-
digits
public static final java.lang.String digits
digit characters- See Also:
- Constant Field Values
-
lowercaseLetters
public static final java.lang.String lowercaseLetters
lower-case letter characters- See Also:
- Constant Field Values
-
uppercaseLetters
public static final java.lang.String uppercaseLetters
upper-case letter characters- See Also:
- Constant Field Values
-
letters
public static final java.lang.String letters
letter characters- See Also:
- Constant Field Values
-
decimalPointDelimiter
public static final java.lang.String decimalPointDelimiter
decimal point character differs by language and culture- See Also:
- Constant Field Values
-
phoneNumberDelimiters
public static final java.lang.String phoneNumberDelimiters
non-digit characters which are allowed in phone numbers- See Also:
- Constant Field Values
-
validUSPhoneChars
public static final java.lang.String validUSPhoneChars
characters which are allowed in US phone numbers- See Also:
- Constant Field Values
-
validWorldPhoneChars
public static final java.lang.String validWorldPhoneChars
characters which are allowed in international phone numbers(a leading + is OK)- See Also:
- Constant Field Values
-
SSNDelimiters
public static final java.lang.String SSNDelimiters
non-digit characters which are allowed in Social Security Numbers- See Also:
- Constant Field Values
-
validSSNChars
public static final java.lang.String validSSNChars
characters which are allowed in Social Security Numbers- See Also:
- Constant Field Values
-
digitsInSocialSecurityNumber
public static final int digitsInSocialSecurityNumber
U.S. Social Security Numbers have 9 digits. They are formatted as 123-45-6789.- See Also:
- Constant Field Values
-
digitsInUSPhoneNumber
public static final int digitsInUSPhoneNumber
U.S. phone numbers have 10 digits. They are formatted as 123 456 7890 or(123) 456-7890.- See Also:
- Constant Field Values
-
digitsInUSPhoneAreaCode
public static final int digitsInUSPhoneAreaCode
- See Also:
- Constant Field Values
-
digitsInUSPhoneMainNumber
public static final int digitsInUSPhoneMainNumber
- See Also:
- Constant Field Values
-
ZipCodeDelimiters
public static final java.lang.String ZipCodeDelimiters
non-digit characters which are allowed in ZIP Codes- See Also:
- Constant Field Values
-
ZipCodeDelimeter
public static final java.lang.String ZipCodeDelimeter
our preferred delimiter for reformatting ZIP Codes- See Also:
- Constant Field Values
-
validZipCodeChars
public static final java.lang.String validZipCodeChars
characters which are allowed in Social Security Numbers- See Also:
- Constant Field Values
-
digitsInZipCode1
public static final int digitsInZipCode1
U.S. ZIP codes have 5 or 9 digits. They are formatted as 12345 or 12345-6789.- See Also:
- Constant Field Values
-
digitsInZipCode2
public static final int digitsInZipCode2
U.S. ZIP codes have 5 or 9 digits. They are formatted as 12345 or 12345-6789.- See Also:
- Constant Field Values
-
creditCardDelimiters
public static final java.lang.String creditCardDelimiters
non-digit characters which are allowed in credit card numbers- See Also:
- Constant Field Values
-
USStateCodeDelimiter
public static final java.lang.String USStateCodeDelimiter
Delimiter for USStateCodes String- See Also:
- Constant Field Values
-
USStateCodes
public static final java.lang.String USStateCodes
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
-
ContiguousUSStateCodes
public static final java.lang.String ContiguousUSStateCodes
Valid contiguous U.S. postal codes- See Also:
- Constant Field Values
-
-
Method Detail
-
areEqual
public static boolean areEqual(java.lang.Object obj, java.lang.Object obj2)
-
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.
-
stripCharsNotInBag
public static java.lang.String stripCharsNotInBag(java.lang.String s, java.lang.String bag)
Removes all characters which do NOT appear in string bag from string s.
-
stripWhitespace
public static java.lang.String stripWhitespace(java.lang.String s)
Removes all whitespace characters from s. Member whitespace(see above) defines which characters are considered whitespace.
-
charInString
public static boolean charInString(char c, java.lang.String s)
Returns true if single character c(actually a string) is contained within string s.
-
stripInitialWhitespace
public static java.lang.String stripInitialWhitespace(java.lang.String s)
Removes initial(leading) whitespace characters from s. Member whitespace(see above) defines which characters are considered whitespace.
-
isLetter
public static boolean isLetter(char c)
Returns true if character c is an English letter (A .. Z, a..z). NOTE: Need i18n version to support European characters. This could be tricky due to different character sets and orderings for various languages and platforms.
-
isDigit
public static boolean isDigit(char c)
Returns true if character c is a digit (0 .. 9).
-
isLetterOrDigit
public static boolean isLetterOrDigit(char c)
Returns true if character c is a letter or digit.
-
isHexDigit
public static boolean isHexDigit(char c)
Returns true if character c is a letter or digit.
-
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.
-
isSignedInteger
public static boolean isSignedInteger(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.
-
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
-
isSolo
public static boolean isSolo(java.lang.String cc)
Checks to see if the cc number is a valid Solo 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 Solo card number, false otherwise
-
isVisaElectron
public static boolean isVisaElectron(java.lang.String cc)
Checks to see if the cc number is a valid Visa Electron number- Parameters:
cc
- - a string representing a credit card number; Sample number: 4175000000000001(16 digits)- Returns:
- true, if the credit card number is a valid Visa Electron 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 typecardNumberPassed
- - 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
-
isNotPoBox
public static boolean isNotPoBox(java.lang.String s)
isNotPoBox returns true if address argument does not contain anything that looks like a a PO Box.
-
isValidUpc
public static boolean isValidUpc(java.lang.String upc)
-
calcUpcChecksum
public static char calcUpcChecksum(java.lang.String upc)
-
isValidEan
public static boolean isValidEan(java.lang.String ean)
-
calcChecksum
public static char calcChecksum(java.lang.String value, int length)
-
checkValidDatabaseId
public static java.lang.String checkValidDatabaseId(java.lang.String fieldStr)
-
isValidDatabaseId
public static boolean isValidDatabaseId(java.lang.String fieldStr, java.lang.StringBuffer errorDetails)
-
isValidDatabaseId
public static boolean isValidDatabaseId(java.lang.String fieldStr, java.lang.StringBuilder errorDetails)
-
isValidPhoneNumber
public static boolean isValidPhoneNumber(java.lang.String phoneNumber, Delegator delegator)
-
isValidPhoneNumber
public static boolean isValidPhoneNumber(java.lang.String phoneNumber, java.lang.String geoId, Delegator delegator)
-
-