\CodeIgniter\ValidationCreditCardRules

Class CreditCardRules

Provides validation methods for common credit-card inputs.

Summary

Methods
Properties
Constants
valid_cc_number()
No public properties found
No constants found
isValidLuhn()
$cards
N/A
No private methods found
No private properties found
N/A

Properties

$cards

$cards : array

The cards that we support, with the defining details:

name - The type of card as found in the form. Must match the user's value length - List of possible lengths for the card number prefixes - List of possible prefixes for the card checkdigit - Boolean on whether we should do a modulus10 check on the numbers.

Type

array

Methods

valid_cc_number()

valid_cc_number(string  $ccNumber = null, string  $type, array  $data) : boolean

Verifies that a credit card number is valid and matches the known formats for a wide number of credit card types. This does not verify that the card is a valid card, only that the number is formatted correctly.

Example: $rules = [ 'cc_num' => 'valid_cc_number[visa]' ];

Parameters

string $ccNumber
string $type
array $data

Returns

boolean

isValidLuhn()

isValidLuhn(string  $number = null) : boolean

Checks the given number to see if the number passing a Luhn check.

Parameters

string $number

Returns

boolean