示例#1
0
 public function check($data)
 {
     foreach ($this->rules as $item) {
         $field = $item[0];
         $value = isset($data[$field]) ? $data[$field] : null;
         $rule = $item[1];
         $param1 = isset($item[2]) ? $item[2] : null;
         $param2 = isset($item[3]) ? $item[3] : null;
         $message = isset($item[4]) ? $item[4] : $this->messages[$rule];
         if ($rule == 'matches') {
             $valid = Valid::matches($data, $field, $param1);
         } elseif ($rule == 'notEmpty' || $rule == 'is') {
             $valid = Valid::$rule($value, $param1, $param2);
         } else {
             $valid = !$value || Valid::$rule($value, $param1, $param2);
         }
         if (!$valid && empty($this->errors[$field])) {
             $message = Str::insert($message, compact('field', 'value', 'rule', 'param1', 'param2'));
             $this->errors[$field] = $message;
         }
     }
     return $this->errors;
 }
示例#2
0
文件: DB.php 项目: Acidburn0zzz/OEM
 public static function quoteInto($str, $data, $options = array())
 {
     return Str::insert($str, self::quote($data), $options);
 }
示例#3
0
 public function testInsert()
 {
     $this->assertEquals('FóóbąR:baż', Str::insert('Fó:óneR\\:baż', array('óne' => 'óbą')));
     $this->assertEquals('FooBar[Baz]', Str::insert('Foo[óne].[Baz]', array('óne' => 'Bar'), array('before' => '[', 'after' => ']', 'escape' => '.')));
 }
示例#4
0
 /**
  * @return StrObject
  */
 public function insert($data, $options = array())
 {
     $value = Str::insert($this->value, $data, $options);
     return new self($value);
 }