【问题标题】:PHP Restler API inputvalidation with multiple params using @typePHP Restler API inputvalidation 使用 @type 的多个参数
【发布时间】:2016-03-12 05:01:51
【问题描述】:

我目前正在尝试在一个简单的类中验证 som 字符串:

  class followup
{

    /**
    *@url POST {varCvr}
    *
    *@param string $varText {@from path}
    *@param string $datTask {@from path}{@type datetime}
    *@param string $datRemind {@from path}{@type datetime}
    *
    */
    function post($varCvr, $varText, $datTask, $datRemind)
    { ......

当我尝试 POST 到 https://MyHost/followup/DK26851300?varText=Test&datTask=2015-12-04 14:20:07&datRemind=2015-12-11 11:00:00 (是 URL_encoded,只是为了便于阅读)我得到以下响应:

{
"error": {
    "code": 400,
    "message": "Bad Request: Invalid value specified for `varText`. Expecting date and time in `YYYY-MM-DD HH:MM:SS` format, such as `2015-12-07 15:34:52`"
},
"debug": {
    "source": "Validator.php:430 at validate stage",
    "stages": {
        "success": [
            "get",
            "route",
            "negotiate"
        ],
        "failure": [
            "validate",
            "message"
        ]
    }
}

}

这是什么原因?感谢您的帮助!

【问题讨论】:

    标签: php restler


    【解决方案1】:

    我在将@param 添加到第一个变量时解决了这个问题:

     /**
    *@url POST {varCvr}
    *@param string $varCvr {@from path}
    *@param string $varText {@from path}
    *@param string $datTask {@from path}{@type datetime}
    *@param string $datRemind {@from path}{@type datetime}
    *
    */
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-17
      • 1970-01-01
      • 2019-01-14
      相关资源
      最近更新 更多