如何在Kohana 3.2验证对象上调用trim函数? [英] How do I call the trim function on a Kohana 3.2 validation object?

查看:60
本文介绍了如何在Kohana 3.2验证对象上调用trim函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Kohana 3.2中的验证对象上调用 trim 函数?我正在使用:

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');

推荐答案

验证对象从3.2版本开始才可读.在创建Validation对象之前过滤输入,如下所示:

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

这篇关于如何在Kohana 3.2验证对象上调用trim函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆