当前位置: 首页>>代码示例>>PHP>>正文


PHP Validator::isCreditCard方法代码示例

本文整理汇总了PHP中lithium\util\Validator::isCreditCard方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::isCreditCard方法的具体用法?PHP Validator::isCreditCard怎么用?PHP Validator::isCreditCard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lithium\util\Validator的用法示例。


在下文中一共展示了Validator::isCreditCard方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCreditCardValidation

 /**
  * Tests credit card validation for numbers in various vendors' formats.
  */
 public function testCreditCardValidation()
 {
     /* American Express */
     $this->assertTrue(Validator::isCreditCard('370482756063980', 'amex'));
     $this->assertTrue(Validator::isCreditCard('3491-0643-3773-483', 'amex'));
     $this->assertTrue(Validator::isCreditCard('344671486204764', 'amex'));
     $this->assertTrue(Validator::isCreditCard('344042544509943', 'amex'));
     $this->assertTrue(Validator::isCreditCard('377147515754475', 'amex'));
     $this->assertTrue(Validator::isCreditCard('375239372816422', 'amex'));
     $this->assertTrue(Validator::isCreditCard('376294341957707', 'amex'));
     $this->assertTrue(Validator::isCreditCard('341779292230411', 'amex'));
     $this->assertTrue(Validator::isCreditCard('341646919853372', 'amex'));
     $this->assertTrue(Validator::isCreditCard('348498616319346', 'amex', array('deep' => true)));
     $this->assertFalse(Validator::isCreditCard('5610376649499352', 'amex'));
     /* BankCard */
     $this->assertTrue(Validator::isCreditCard('5610 7458 6741 3420', 'bankcard'));
     $this->assertTrue(Validator::isCreditCard('5610376649499352', 'bankcard'));
     $this->assertTrue(Validator::isCreditCard('5610091936000694', 'bankcard'));
     $this->assertTrue(Validator::isCreditCard('5602248780118788', 'bankcard'));
     $this->assertTrue(Validator::isCreditCard('5610631567676765', 'bankcard'));
     $this->assertTrue(Validator::isCreditCard('5602238211270795', 'bankcard'));
     $this->assertTrue(Validator::isCreditCard('5610173951215470', 'bankcard'));
     $this->assertTrue(Validator::isCreditCard('5610139705753702', 'bankcard'));
     $this->assertTrue(Validator::isCreditCard('5602226032150551', 'bankcard'));
     $this->assertTrue(Validator::isCreditCard('5602223993735777', 'bankcard'));
     $this->assertFalse(Validator::isCreditCard('30155483651028', 'bankcard'));
     /* Diners Club 14 */
     $this->assertTrue(Validator::isCreditCard('30155483651028', 'diners'));
     $this->assertTrue(Validator::isCreditCard('36371312803821', 'diners'));
     $this->assertTrue(Validator::isCreditCard('38801277489875', 'diners'));
     $this->assertTrue(Validator::isCreditCard('30348560464296', 'diners'));
     $this->assertTrue(Validator::isCreditCard('30349040317708', 'diners'));
     $this->assertTrue(Validator::isCreditCard('36567413559978', 'diners'));
     $this->assertTrue(Validator::isCreditCard('36051554732702', 'diners'));
     $this->assertTrue(Validator::isCreditCard('30391842198191', 'diners'));
     $this->assertTrue(Validator::isCreditCard('30172682197745', 'diners'));
     $this->assertTrue(Validator::isCreditCard('30162056566641', 'diners'));
     $this->assertTrue(Validator::isCreditCard('30085066927745', 'diners'));
     $this->assertTrue(Validator::isCreditCard('36519025221976', 'diners'));
     $this->assertTrue(Validator::isCreditCard('30372679371044', 'diners'));
     $this->assertTrue(Validator::isCreditCard('38913939150124', 'diners'));
     $this->assertTrue(Validator::isCreditCard('36852899094637', 'diners'));
     $this->assertTrue(Validator::isCreditCard('30138041971120', 'diners'));
     $this->assertTrue(Validator::isCreditCard('36184047836838', 'diners'));
     $this->assertTrue(Validator::isCreditCard('30057460264462', 'diners'));
     $this->assertTrue(Validator::isCreditCard('38980165212050', 'diners'));
     $this->assertTrue(Validator::isCreditCard('30356516881240', 'diners'));
     $this->assertTrue(Validator::isCreditCard('38744810033182', 'diners'));
     $this->assertTrue(Validator::isCreditCard('30173638706621', 'diners'));
     $this->assertTrue(Validator::isCreditCard('30158334709185', 'diners'));
     $this->assertTrue(Validator::isCreditCard('30195413721186', 'diners'));
     $this->assertTrue(Validator::isCreditCard('38863347694793', 'diners'));
     $this->assertTrue(Validator::isCreditCard('30275627009113', 'diners'));
     $this->assertTrue(Validator::isCreditCard('30242860404971', 'diners'));
     $this->assertTrue(Validator::isCreditCard('30081877595151', 'diners'));
     $this->assertTrue(Validator::isCreditCard('38053196067461', 'diners'));
     $this->assertTrue(Validator::isCreditCard('36520379984870', 'diners'));
     /* 2004 MasterCard/Diners Club Alliance International 14 */
     $this->assertTrue(Validator::isCreditCard('36747701998969', 'diners'));
     $this->assertTrue(Validator::isCreditCard('36427861123159', 'diners'));
     $this->assertTrue(Validator::isCreditCard('36150537602386', 'diners'));
     $this->assertTrue(Validator::isCreditCard('36582388820610', 'diners'));
     $this->assertTrue(Validator::isCreditCard('36729045250216', 'diners'));
     /* 2004 MasterCard/Diners Club Alliance US & Canada 16 */
     $this->assertTrue(Validator::isCreditCard('5597511346169950', 'diners'));
     $this->assertTrue(Validator::isCreditCard('5526443162217562', 'diners'));
     $this->assertTrue(Validator::isCreditCard('5577265786122391', 'diners'));
     $this->assertTrue(Validator::isCreditCard('5534061404676989', 'diners'));
     $this->assertTrue(Validator::isCreditCard('5545313588374502', 'diners'));
     $this->assertFalse(Validator::isCreditCard('6011802876467237', 'diners'));
     /* Discover */
     $this->assertTrue(Validator::isCreditCard('6011802876467237', 'disc'));
     $this->assertTrue(Validator::isCreditCard('6506432777720955', 'disc'));
     $this->assertTrue(Validator::isCreditCard('6011126265283942', 'disc'));
     $this->assertTrue(Validator::isCreditCard('6502187151579252', 'disc'));
     $this->assertTrue(Validator::isCreditCard('6506600836002298', 'disc'));
     $this->assertTrue(Validator::isCreditCard('6504376463615189', 'disc'));
     $this->assertTrue(Validator::isCreditCard('6011440907005377', 'disc'));
     $this->assertTrue(Validator::isCreditCard('6509735979634270', 'disc'));
     $this->assertTrue(Validator::isCreditCard('6011422366775856', 'disc'));
     $this->assertTrue(Validator::isCreditCard('6500976374623323', 'disc'));
     $this->assertFalse(Validator::isCreditCard('201496944158937', 'disc'));
     /* enRoute */
     $this->assertTrue(Validator::isCreditCard('201496944158937', 'enroute'));
     $this->assertTrue(Validator::isCreditCard('214945833739665', 'enroute'));
     $this->assertTrue(Validator::isCreditCard('214982692491187', 'enroute'));
     $this->assertTrue(Validator::isCreditCard('214901395949424', 'enroute'));
     $this->assertTrue(Validator::isCreditCard('201480676269187', 'enroute'));
     $this->assertTrue(Validator::isCreditCard('214911922887807', 'enroute'));
     $this->assertTrue(Validator::isCreditCard('201485025457250', 'enroute'));
     $this->assertTrue(Validator::isCreditCard('201402662758866', 'enroute'));
     $this->assertTrue(Validator::isCreditCard('214981579370225', 'enroute'));
     $this->assertTrue(Validator::isCreditCard('201447595859877', 'enroute'));
     $this->assertFalse(Validator::isCreditCard('210034762247893', 'enroute'));
     /* JCB 15 digit */
     $this->assertTrue(Validator::isCreditCard('210034762247893', 'jcb'));
     $this->assertTrue(Validator::isCreditCard('180078671678892', 'jcb'));
//.........这里部分代码省略.........
开发者ID:nilamdoc,项目名称:KYCGlobal,代码行数:101,代码来源:ValidatorTest.php

示例2: testCheckAny

 /**
  * Verifies that if validating with _any_, any format for
  * a rule will match. See issue #888 for more information.
  */
 public function testCheckAny()
 {
     $this->assertTrue(Validator::isCreditCard('4242424242424242', 'visa'));
     $this->assertTrue(Validator::isCreditCard('4242424242424242'));
 }
开发者ID:fedeisas,项目名称:lithium,代码行数:9,代码来源:ValidatorTest.php


注:本文中的lithium\util\Validator::isCreditCard方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。