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 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?