1 回答
TA贡献2021条经验 获得超8个赞
拉维尔5:
使用以下手动验证过程:
// use Validator facade after namespace & replace below line of code
//$this->validate($request, [
// 'email' => 'required|email|max:255|unique:users'
//]);
$validator = Validator::make($request->all(), [
'email' => 'required|email|max:255|unique:users'
]);
if ($validator->fails()) {
$errors = $validator->errors();
if ($errors->has('email')) {
# Return json response with first error.
return response()->json([
'success' => false,
'error' => $errors->first('email')
]);
}
}
访问更多参考:Laravel Doc
- 1 回答
- 0 关注
- 143 浏览
添加回答
举报