【发布时间】:2018-07-18 09:43:40
【问题描述】:
我最近升级到 laravel 5.4(从 5.2)以使用 nullable 验证规则。
我有一个字段act_post_code,它可以是integer 或null。所以我在Request 类中提供了以下规则。
'act_post_code' => 'integer|nullable'
在使用 form-data 的 Postman 中,我提供了一个键 = act_post_code,其值 = null。
我得到的回复如下:
{
"act_post_code": [
"The act post code must be an integer."
]
}
【问题讨论】:
-
在规则列表中的整数前使用可为空。
-
@btl 没用。同样的反应。
-
act_post_code在您的表定义中是否可以为空? -
我相信是的。
act_post_codevarchar(4) 默认为空, -
如果你尝试只使用 nullable 会发生什么
标签: php laravel laravel-5.3 postman laravel-validation