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; }
public static function quoteInto($str, $data, $options = array()) { return Str::insert($str, self::quote($data), $options); }
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' => '.'))); }
/** * @return StrObject */ public function insert($data, $options = array()) { $value = Str::insert($this->value, $data, $options); return new self($value); }