我需要确保在我的 Zend_Rest_Controller 中提供了几个参数。
这是我的代码:
public function indexAction() {
$filters = array(
'locid' => array('HtmlEntities', 'StringTrim')
);
$validators = array(
'locid' => array('NotEmpty')
);
$input = new Zend_Filter_Input($filters, $validators);
$input->setData($this->getRequest()->getParams());
if($input->isValid())
{
echo "Correct";
}
else
{
echo "missing/invalid params";
}
}
但是,如果我提供这样格式的 url(没有查询字符串):
localhost/ws
它返回“正确”,而不是“缺少/无效参数”。
验证器中包含任何简单的解决方案或参数吗?
谢谢。