0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

laravelのリクエストクラスのバリデーションで気を付けること

Posted at

laravelでのバリデーションはformRequestクラスで定義しているのですが、
小一時間つまらぬミスで、苦闘していたので共有します。

app/Http/Requests/UpdateRequest.php
/**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $rules = [
            'name' => 'required|string',
            'detail' => 'required',
            'movie_file' => 'required|mimes:mp4, zip|max:2048',
            'image_file.*' => 'required|mimes:jpg, png, jpeg',
        ];
        return $rules;
    }

上記、実はバリデーション通過時に通りません。

mimesタイプのmimes:mp4, zipの空欄があるとバリデーション通過しません。
なぜかは、分からないのでどなたか教えて頂けると助かります!

カンマの後は、スペース入れる癖があるので気を付けないとですね。。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?