Class SwiftUtil
Global utility methods.
Inheritance
Inherited Members
Namespace: Subsembly.Swift
Assembly: Subsembly.Sepa.dll
Syntax
public static class SwiftUtil
Fields
MAXCREDITCARDNOLENGTH
The maximum length of a credit card number according to IsValidCreditCardNo(String).
Declaration
public const int MAXCREDITCARDNOLENGTH = 16
Field Value
Type | Description |
---|---|
System.Int32 |
Remarks
Actually the official length range for payment card numbers is 8 through 19 digits. But in real life all credit card numbers are between 12 and 16 digits. Hence this constant has the value 16.
MINCREDITCARDNOLENGTH
The minimum length of a credit card number according to IsValidCreditCardNo(String).
Declaration
public const int MINCREDITCARDNOLENGTH = 12
Field Value
Type | Description |
---|---|
System.Int32 |
Remarks
Actually the official length range for payment card numbers is 8 through 19 digits. But in real life all credit card numbers are between 12 and 16 digits. Hence this constant has the value 12.
Methods
AppendLuhn(String)
Computes and appends a Luhn check digit to the given string.
Declaration
public static string AppendLuhn(string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s |
Returns
Type | Description |
---|---|
System.String |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The parameter |
CoalesceSpaces(String)
Declaration
public static string CoalesceSpaces(string sText)
Parameters
Type | Name | Description |
---|---|---|
System.String | sText |
Returns
Type | Description |
---|---|
System.String |
ComputeLuhn(String, Int32)
Computes the Luhn check digit for the given string. The Luhn check is used, for example, with ISIN numbers and credit card numbers.
Declaration
public static char ComputeLuhn(string s, int n)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The string to compute the Luhn check digit for. Must not be |
System.Int32 | n | The number of characters to include in the check digit computation. Only the first
|
Returns
Type | Description |
---|---|
System.Char | The computed check digit, which is in the range from '0' to '9'. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The parameter |
System.ArgumentException | The parameter |
System.FormatException | The parameter |
IsValidCreditCardNo(String)
Fully validates the given credit card number
Declaration
public static bool IsValidCreditCardNo(string sCreditCardNo)
Parameters
Type | Name | Description |
---|---|---|
System.String | sCreditCardNo |
Returns
Type | Description |
---|---|
System.Boolean | If the given string looks like a valid credit card number, then |
Remarks
Verifies the length, the character set and the Luhn check digit of the given credit card number. It does not verify the validity of the leading digits, yet.
LuhnCheck(String)
Computes and checks the check digits from the given string according to the Luhn algorithm. The Luhn check is used, for example, with ISIN numbers and credit card numbers.
Declaration
public static bool LuhnCheck(string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The string to check. If this is null or empty, then the result will be false. |
Returns
Type | Description |
---|---|
System.Boolean | If the given string is correct accoring to the Luhn algorithm, then |