LoginSignup
1
1

More than 1 year has passed since last update.

laravel バリデーション filled

Posted at

概要

  • キーが送られた場合、空ではないことをバリデートするfilledについてまとめる。

記載方法

  • このバリデーションルールは「キーが送られている」 & 「値が空」の場合弾く。

  • 逆に「キーが送られている」 & 「値が入っている」と「キーが送られていないとき」は特にエラーを出さない。

  • なので、更新系の処理などの不特定の「不特定数のキーが送られてくるが、送られたキーの必須は許したくない」ときに使える。

  • 下記のように設定する。(content_1キーが送られたとき値が空ではないことをチェック)

    formRequest.php
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'content_1' => ['filled'],
        ];
    }
    

参考文献

1
1
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
1
1