0
这是我的InfoModel中的验证。 我想验证生日,但“生日”字段为int(8) in DB。不幸的是我没有修改MySQL数据库表的权限。现在如何验证它?生日验证整型生日
例:19800101
我试过,但我想不出解决的生日转换为字符串。
var $validate = array(
'job_id' => array('rule' => 'notEmpty' , 'message' => 'Text here'),
'sex_id' => array('rule' => 'notEmpty' , 'message' => 'Text here'),
'first_name' => array('rule' => array('between', 1, 5) , 'message' => 'Text here'),
'last_name' => array('rule' => array('between', 1, 5) , 'message' => ''),
//'birthday' => array('rule' => 'some regex', 'message' => 'Text here')
);
当生日是INT是否行得通?我需要转换$ check吗? – Emerald214 2012-03-29 10:12:04
是的,它的工作原理。我使用'preg_match()'分隔日,月和年。只需在模型中包含函数'validateBirthday'并更改'$ validate'变量。 – 2012-03-29 10:14:49