Overview

Namespaces

  • None
  • Wei
    • Validator

Classes

  • All
  • AllOf
  • Alnum
  • Alpha
  • BaseValidator
  • Between
  • Blank
  • Callback
  • CharLength
  • Chinese
  • Color
  • Contains
  • CreditCard
  • Date
  • DateTime
  • Decimal
  • Digit
  • Dir
  • DivisibleBy
  • DoubleByte
  • Email
  • EndsWith
  • EqualTo
  • Exists
  • FieldExists
  • File
  • GreaterThan
  • GreaterThanOrEqual
  • IdCardCn
  • IdCardHk
  • IdCardMo
  • IdCardTw
  • IdenticalTo
  • Image
  • In
  • Ip
  • Length
  • LessThan
  • LessThanOrEqual
  • Lowercase
  • Luhn
  • MaxLength
  • MinLength
  • MobileCn
  • NaturalNumber
  • NoneOf
  • Null
  • Number
  • OneOf
  • Password
  • Phone
  • PhoneCn
  • PlateNumberCn
  • PositiveInteger
  • PostcodeCn
  • Present
  • QQ
  • RecordExists
  • Regex
  • Required
  • SomeOf
  • StartsWith
  • Time
  • Tld
  • Type
  • Uppercase
  • Url
  • Uuid
  • Overview
  • Namespace
  • Class

Class CreditCard

Check if the input is valid credit card number

The type of credit card could be American Express, Diners Club, Discover, JCB, MasterCard, China UnionPay or Visa

Wei\Base
Extended by Wei\Validator\BaseValidator
Extended by Wei\Validator\CreditCard
Namespace: Wei\Validator
Author: Twin Huang twinhuang@qq.com
Located at Validator/CreditCard.php
Methods summary
public boolean
# __invoke( mixed $input, $type = null )

Validate the input value

Validate the input value

Parameters

$input
$type

Returns

boolean

Overrides

Wei\Validator\BaseValidator::__invoke()
protected boolean
# doValidate( mixed $input )

Validate the input value (ignore the $negative property)

Validate the input value (ignore the $negative property)

Parameters

$input
The input to be validated

Returns

boolean
public boolean
# validateLuhn( string $input )

Check if the input is valid luhn number

Check if the input is valid luhn number

Parameters

$input

Returns

boolean

Link

https://gist.github.com/troelskn/1287893
public
# validateType( $input )
public Wei\Validator\CreditCard
# setType( string|array $type )

Set allowed credit card types, could be array, string separated by comma(,) or string "all" means all supported types

Set allowed credit card types, could be array, string separated by comma(,) or string "all" means all supported types

Parameters

$type

Returns

Wei\Validator\CreditCard

Throws

InvalidArgumentException
When parameter is not array or string
Methods inherited from Wei\Validator\BaseValidator
addError(), getErrors(), getFirstMessage(), getJoinedMessage(), getMessages(), getName(), hasError(), isString(), isValid(), loadTranslationMessages(), setMessages(), setName(), storeOption()
Methods inherited from Wei\Base
__call(), __construct(), __get(), getOption(), setOption()
Magic methods inherited from Wei\Validator\BaseValidator
t()
Properties summary
protected string $invalidMessage
# '%name% must be valid credit card number'
protected string $negativeMessage

The common message for negative validator

The common message for negative validator

# '%name% must not be valid credit card number'
protected array $type

Allowed credit cards name

Allowed credit cards name

# array()
protected array $cards

The array contains card name, length and validation pattern

The array contains card name, length and validation pattern

Link

http://en.wikipedia.org/wiki/Credit_card_number
# array( 'Amex' => array( // American Express 'length' => 15, 'pattern' => '34|37' ), 'DinersClub' => array( 'length' => 14, 'pattern' => '30|36|38' ), 'Discover' => array( 'length' => 16, 'pattern' => '6011|64|65' ), 'JCB' => array( 'length' => array(15, 16), 'pattern' => '2131|1800|35' ), 'MasterCard' => array( 'length' => 16, 'pattern' => '51|52|53|54|55' ), 'UnionPay' => array( 'length' => 16, 'pattern' => '62' ), 'Visa' => array( 'length' => array(13, 16), 'pattern' => '4' ) )
Properties inherited from Wei\Validator\BaseValidator
$errors, $name, $negative, $notStringMessage, $validator
Properties inherited from Wei\Base
$providers, $wei
Magic properties inherited from Wei\Validator\BaseValidator
$t
Wei Framework API documentation generated by ApiGen