示例#1
0
文件: Chain.php 项目: lytc/sloths
 public static function fromArray(array $rules)
 {
     foreach ($rules as $name => &$rule) {
         if ($rule instanceof ValidatorInterface) {
             continue;
         }
         if (is_string($name)) {
             $args = $rule;
         } else {
             $name = $rule;
             $args = [];
         }
         if (!is_array($args)) {
             $args = [$args];
         }
         $rule = Validator::createRule($name, $args);
     }
     return new static($rules);
 }
示例#2
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testCreateRuleWithInvalidArgShouldThrowAnException()
 {
     Validator::createRule(new \stdClass());
 }