Reputation: 377
How can I call the trim function on a validation object in Kohana 3.2? I am using:
$post = Validation::factory($this->request->post());
$post->rule('Email', 'trim');
Upvotes: 3
Views: 1869
Reputation: 17735
In addition to Darsstar reply - if you need recursive version of array_map
, check out Arr::map function:
$post = Arr::map('trim', $this->request->post());
Upvotes: 2
Reputation: 1895
Validation objects are read only as of 3.2. Filter the input before creating the Validation object like so:
$post = array_map('trim', $this->request->post()); // $post[key] = expression; if it is for one specific value
$post = Validation::factory($post);
// set validation rules etc
Upvotes: 4