这里是输入值:FIRST_TIME_ARRIVAL_DATE_AT_DAW : 2016-21-5 17:21:35
这里是验证规则:
public static $createRules = [
'FIRST_TIME_ARRIVAL_DATE_AT_DAW' => 'date_format:"Y-m-d H:i:s"',
];
并且它没有验证,它返回:
{"CELLS_EXPIRY_DATE":["The FIRST TIME ARRIVAL DATE AT DAW does not match the format Y-m-d H:i:s."]
编辑: 这是我的控制器的样子:
$validator = Validator::make($request->all(),BatteryAssets::$createRules);
if ($validator->fails()) {
return ['success' => 0, 'data' => 'Input error','errors' => $validator->messages()->toJson()];
}
所以$validator->messages()->toJson()
会返回验证错误
答案 0 :(得分:2)
format Y-m-d H:i:s need be 2016-21-05 17:21:35
答案 1 :(得分:0)
将'date_format:"Y-m-d H:i:s"'
更改为'date_format:Y-m-d H:i:s'