我最近升级到了laravel 5.4(从5.2),以使用nullable
验证规则。
我有一个字段act_post_code
,它可以是一个integer
或null
。因此,在我的Request
类中提供了以下规则。
'act_post_code' => 'integer|nullable'
在 Postman 中使用
form-data
,我提供了一个键为 act_post_code
,值为null
。我得到的响应如下:
{
"act_post_code": [
"The act post code must be an integer."
]
}
act_post_code
是否可为空? - user320487null
... 嗯,那可能是 postman 解释 null 的方式,被视为字符串了? - Parampal Pooni