When I send wrong data to server using AJAX, Laravel checkes it and throw message error:
The given data was invalid.
My requests validation is:
class RegistrationRequest extends FormRequest
{
public function authorize()
{
return true;
}
public function messages()
{
return [
'email' => 'required|email|unique:users',
'password' => 'required|min:6',
];
}
public function rules()
{
return [
'email' => 'required|email|unique:users',
'password' => 'required|min:6',
];
}
}
Using is:
public function register(RegistrationRequest $request){}
Handler exceptions is:
public function render($request, Exception $exception)
{
if ($exception instanceof ValidationException) {
return response()->json(['type' => 'error',
'codes' => [$exception->getMessage()]], 400);
}
return parent::render($request, $exception);
}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2mKkWjX
via IFTTT
Aucun commentaire:
Enregistrer un commentaire