【发布时间】:2011-12-15 22:04:00
【问题描述】:
如何在 Kohana 3.2 中对验证对象调用 trim 函数?我正在使用:
$post = Validation::factory($this->request->post());
$post->rule('Email', 'trim');
【问题讨论】:
标签: kohana
如何在 Kohana 3.2 中对验证对象调用 trim 函数?我正在使用:
$post = Validation::factory($this->request->post());
$post->rule('Email', 'trim');
【问题讨论】:
标签: kohana
自 3.2 起,验证对象为只读。在创建 Validation 对象之前过滤输入,如下所示:
$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
【讨论】:
除了 Darsstar 回复——如果你需要递归版本的array_map,查看Arr::map函数:
$post = Arr::map('trim', $this->request->post());
【讨论】: