douchuoxuan3177 2017-10-31 07:38
浏览 90
已采纳

laravel验证规则不接受数组的第一个索引

/**
 * Store a newly created resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function store(Request $request) {
    $rules = [
        'translations'                  => 'required|array',
        'translations.*.language_code'  => 'required|exists:app_languages,code',
        'translations.*.name'           => 'required'
    ];

    $this->validate($request, $rules);

    dd("OK");
}

I am using PostMan to test it. Everything is ok for array's second parameter. But it does not accept name 0 index or array.

enter image description here

When i didn't send first index :

enter image description here

UPDATE

It is Postman's bug. I added same parameter then replace it, it works.

enter image description here

  • 写回答

2条回答 默认 最新

  • dongshuo8756 2017-10-31 07:55
    关注

    It is Postman's bug. I added same parameter then replace it, it works.

    I do not know, why it didn't accept and now it accept lol.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误