对于以下请求,当正文参数作为 JSON 发送时,它总是验证请求(因为没有触发验证规则),但是当以 form-data 或 form-urlencoded 发送时,它会通过验证规则。这是 Laravel 的限制吗?
namespace App\Api\Requests\OrganizationUser;
use App\Api\Constants\PlatformRoles;
use Framework\Http\Requests\APIFormRequest;
class CreateNewUserRequest extends APIFormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'bail|required|string|max:255',
'access' => 'present|array',
'access.*.access_type' => ['bail', 'sometimes', 'string'],
'access.*.id' => ['bail', 'sometimes', 'string']
];
}
}