ValidationUtil

Kind of class:public class
Package:org.casalib.util
Inherits from:none
Version:08/30/08
Author:Aaron Clinger
Classpath:org.casalib.util.ValidationUtil
File last modified:Thursday, 19 February 2009, 11:33:36
Utilities for validating common string formats.

Summary


Class methods
  • isEmail (email:String) : Boolean
    • Determines if String is a valid email address.
  • isUsaStateAbbreviation (state:String) : Boolean
    • Determines if String is a valid USA state abbreviation.
  • isCreditCard (cardNumber:String) : Boolean
    • Determines if credit card is valid using the Luhn formula.
  • getCreditCardProvider (cardNumber:String) : String
    • Determines credit card provider by card number.

Class methods

getCreditCardProvider

public static function getCreditCardProvider (
cardNumber:String) : String

Determines credit card provider by card number.
Parameters:
cardNumber:
The credit card number.
Returns:
  • Returns name of the provider; values can be "visa", "mastercard", "discover", "amex", "diners", "other" or "invalid".

isCreditCard

public static function isCreditCard (
cardNumber:String) : Boolean

Determines if credit card is valid using the Luhn formula.
Parameters:
cardNumber:
The credit card number.
Returns:
  • Returns true if String is a valid credit card number; otherwise false.

isEmail

public static function isEmail (
email:String) : Boolean

Determines if String is a valid email address.
Parameters:
email:
String to verify as email.
Returns:
  • Returns true if String is a valid email; otherwise false.

isUsaStateAbbreviation

public static function isUsaStateAbbreviation (
state:String) : Boolean

Determines if String is a valid USA state abbreviation.
Parameters:
state:
String to verify as two letter state abbreviation (includes DC).
Returns:
  • Returns true if String is a state abbreviation; otherwise false.