Laravel对邮递员发送的布尔值的验证失败

时间:2020-05-10 14:43:30

标签: php laravel postman lumen

在我的Lumen API中,我使用Validator门面检查请求正文。请求的private属性之一必须是boolean类型。所以我这样检查我的请求:

$validator = Validator::make($request->all(), [
    'private' => 'required|boolean',
]);

if ($validator->fails()) {
    // invalid request body...
};

因此,我使用x-www-form-urlencoded'格式'在Postman中提出了请求:

enter image description here

但是随后我收到一条错误消息作为响应:

{
    "private": [
        "The private field must be true or false."
    ]
}

但是如果我在邮递员中将true替换为1,它会按预期工作

我在邮递员配置中错过了什么吗?

1 个答案:

答案 0 :(得分:0)

Laravel validation boolean rule检查数据是否为def dfs(row, column, value): if row == R and column == C: answer = max(answer, value) return new_row = row + ~~ new_column = column + ~~ dfs(new_row, new_column, value + board[new_row][new_column]) def solution(board): answer = 0 dfs(0, 0, 0) return answer print(solution(board)) ,我认为当您使用邮递员发送时,值true, false, 1, 0, "1", and "0".的发送方式类似于字符串true