简体   繁体   English

PHP Restler API使用@type的多个参数的inputvalidation

[英]PHP Restler API inputvalidation with multiple params using @type

I'm currently trying to validate som strings in a simple class: 我目前正在尝试在一个简单的类中验证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)
    { ......

When I try to POST to https://MyHost/followup/DK26851300?varText=Test&datTask=2015-12-04 14:20:07&datRemind=2015-12-11 11:00:00 (is URL_encoded, just to be human readable) I get the following Response: 当我尝试发布到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"
        ]
    }
}

} }

What is the reason for this? 这是什么原因呢? Thank you for your help! 谢谢您的帮助!

I've solved the problem while adding @param to the 1st variable: 在第一个变量中添加@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}
*
*/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM