我尝试验证POST请求。
格式为:d.m.Y
(12.1.2017)我的规则required|date_format:d.m.Y
适用于此字段。
我收到此错误消息:
InvalidArgumentException in Carbon.php line 425:
Unexpected data found.
Unexpected data found.
Data missing
如果我将更.
改为-
,甚至/
可以正常使用-> POST数据在匹配规则之前已更改。
我需要使用德语格式。
编辑:我的验证规则:
public function rules()
{
return [
'title' => 'required|max:255',
'expiration_date' => 'required|date_format:d.m.Y',
//'description' => 'required',
'provision_agent' => 'required|integer|between:0,100',
'discount_consumer' => 'required|integer|between:0,100',
'quota' => 'required|integer',
];
}
包装您的格式应该可以正常工作,我刚刚尝试过5.2。
public function rules()
{
return [
'title' => 'required|max:255',
'expiration_date' => 'required|date_format:"d.m.Y"',
//'description' => 'required',
'provision_agent' => 'required|integer|between:0,100',
'discount_consumer' => 'required|integer|between:0,100',
'quota' => 'required|integer',
];
}
但是,您在Carbon.php第425行中的问题InvalidArgumentException中添加的错误:我猜您似乎在使用控制器或模型中的Carbon或模型中的某些地方使用expiration_date
echo Carbon::createFromFormat('Y-m-d', '12.1.2017');
你应该尝试这样的事情
echo Carbon::parse('12.1.2017')->format('Y-m-d')
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句