LoginSignup
0
1

More than 1 year has passed since last update.

【Laravel】配列のバリデーション

Posted at

環境

Laravel v9.5.1 (PHP v8.1.3)

配列のバリデーション

Requestクラスでバリデーションする際に
リクエストパラメータがarrayで、そのarrayの中身のバリデーションをしたいときはワイルドカードを使う。

$requestParams = [
  'post_ids' => [1, 2, 3],
]
public function rules(): array
{
  return [
      'post_ids' => 'required | array',
      'post_ids.*' => 'integer',
  ];
}
0
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
0
1