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


PHP ValidatorChain::getValidators方法代码示例

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


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

示例1: testCanAttachMultipleValidatorsOfTheSameTypeAsDiscreteInstances

 /**
  * @group ZF-412
  */
 public function testCanAttachMultipleValidatorsOfTheSameTypeAsDiscreteInstances()
 {
     $this->validator->addByName('Callback', array('callback' => function ($value) {
         return true;
     }, 'messages' => array('callbackValue' => 'This should not be seen in the messages')));
     $this->validator->addByName('Callback', array('callback' => function ($value) {
         return false;
     }, 'messages' => array('callbackValue' => 'Second callback trapped')));
     $this->assertEquals(2, count($this->validator));
     $validators = $this->validator->getValidators();
     $compare = null;
     foreach ($validators as $validator) {
         $this->assertNotSame($compare, $validator);
         $compare = $validator;
     }
     $this->assertFalse($this->validator->isValid('foo'));
     $messages = $this->validator->getMessages();
     $found = false;
     $test = 'Second callback trapped';
     foreach ($messages as $messageSet) {
         if (is_string($messageSet) && $messageSet === $test) {
             $found = true;
             break;
         }
         if (is_array($messageSet) && in_array('Second callback trapped', $messageSet)) {
             $found = true;
             break;
         }
     }
     $this->assertTrue($found);
 }
开发者ID:nieldm,项目名称:zf2,代码行数:34,代码来源:ValidatorChainTest.php

示例2: testAttachByNameAllowsSpecifyingBreakChainOnFailureFlagViaOptions

 /**
  * @group zfcampus_zf-apigility-admin_89
  * @dataProvider breakChainFlags
  */
 public function testAttachByNameAllowsSpecifyingBreakChainOnFailureFlagViaOptions($option)
 {
     $this->validator->attachByName('GreaterThan', array($option => true, 'min' => 1));
     $this->assertEquals(1, count($this->validator));
     $validators = $this->validator->getValidators();
     $spec = array_shift($validators);
     $this->assertInternalType('array', $spec);
     $this->assertArrayHasKey('instance', $spec);
     $validator = $spec['instance'];
     $this->assertInstanceOf('Zend\\Validator\\GreaterThan', $validator);
     $this->assertArrayHasKey('breakChainOnFailure', $spec);
     $this->assertTrue($spec['breakChainOnFailure']);
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:17,代码来源:ValidatorChainTest.php


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