0
Help us understand the problem. What are the problem?

posted at

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

環境

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',
  ];
}

Register as a new user and use Qiita more conveniently

  1. You can follow users and tags
  2. you can stock useful information
  3. You can make editorial suggestions for articles
What you can do with signing up
0
Help us understand the problem. What are the problem?