For a project with Laravel 4.1, I have a small user interface problem that I would like to solve.
Some inputs make the laravel ajax call blurry, and this works fine. He just sends that value. In laravel, I check with a validator.
public function validate() {
if(Request::ajax()) {
$validation = Validator::make(Input::all(), array(
'email' => 'unique:users|required|email',
'username' => 'required'
));
if($validation->fails()) {
return $validation->messages()->toJson();
}
return "";
}
return "";
}
Although this works, the json line also contains fields that I do not need to check. To be precise, this is the feedback I get:
{"email":["The email field is required."],"username":["The username field is required."]}
But, seeing that this is blurry, I only need the one on which I really check in return. Therefore, if I blur the email, I want to return:
{"email":["The email field is required."]}
Now I know this because my array contains several fields, but I do not want to write a full check for every possible input I have ever made.
: - , , .