shardendu's avatar

Laravel 5.2 - Validation fails without errors when request has files

These are the rules in my CreateUserRequest

public function rules()
    {
        $rules = [
            'name' => 'bail|required|between:3,50|unique:users',
            'username' => 'bail|required|between:3,30|unique:users',
            'email' => 'bail|required|between:3,100|email|unique:users',
            'phone' => 'digits_between:6,22',
            'slots.*.day' => 'in:0,1,2,3,4,5,6,7',
            'slots.*.slot_from' => 'date_format:h:i A',
            'slots.*.slot_to' => 'date_format:h:i A',
            'images' => 'array'
        ];

        $images = $this->file('images');

        if (!empty( $images )) {
            foreach ( $images as $key => $image ) {
                $rules[ sprintf( 'images.%d', $key ) ] = 'mimes:jpeg,png';
            }
        }

        return $rules;
    }

Everything works fine when I don't upload any image - I get right error messages for the validations I've applied. But when there are images in the request the validator fails and outputs no errors. Anyway I can debug this situation?

The problem persists even if I remove image validation completely from the rules. It redirects me back without any errors.

EDIT:

Seems like its the issue with Laravel itself with php 7 https://github.com/laravel/framework/issues/12335

0 likes
2 replies

Please or to participate in this conversation.