How to find undesired output in Laravel/PHP

Viewed 31

I have faced an annoying issue, so in only validation error output, only hard-coded number (2) is being printed at the beginning of JSON response.

2{
"message": "The password field is required.",
"errors": {
    "password": [
        "The password field is required."
    ]
}

}

I guess it is not related to the vendor folder because I already deleted the vendor folder and reinstalled composer dependencies.

I assume it's something echo command that causes this problem. But I can't find where it's. Can someone help me with troubleshooting?

Additionally, I tired another way to validate using Validator facade. It's same.

        $validator = Validator::make($request->all(), [
        'first_name' => 'required|string',
        'last_name' => 'required|string',
        'email' => 'required|string|unique:users,email',
        'mobile' => ['required', 'string', 'unique:users,mobile', new AzeMobile()],
        'password' => 'required|string|confirmed'
    ]);

    dd($validator->fails());

output:

enter image description here

1 Answers

After debugging, I figured out the problem was inside lang/en/validation.php

validation.php

Related