Laravel 数组验证不显示错误消息

首先我可以说在搜索之后我没有找到任何关于这个的解决方案。我像这篇文章一样做验证数组:laravel validation array


我需要验证每个大小数组位置。我写了这个验证代码:


   // Fields validation

    $request->validate([

        'name' => 'required|max:150',

        'theySay' => 'nullable|array',

        'theySay.*' => 'string|max:1000',

        'theyDontSay' => 'nullable|array',

        'theyDontSay.*' => 'string|max:1000',

    ]

其中 theySay 和 theyDontSay 都是字符串数组。在迁移中,我有两个字段(文本),如 1000 个字符的字符串。


        $table->string('text', 1000);

验证工作正常。我的意思是,如果输入大于 1000 个字符的文本,我将无法保存,但……不显示任何错误消息。


我希望错误消息像其他字段一样显示在输入中。


我究竟做错了什么?

http://img1.mukewang.com/6145aa8300017f6015740113.jpg

http://img4.mukewang.com/6145aa8b0001810512810189.jpg

哈士奇WWW
浏览 204回答 2
2回答

HUWWW

'YOUR_FIELD' => '...|...|max:1000| ...'查看 Laravel 验证文档以获取更多信息

MYYA

请将以下代码放入您的刀片文件中以显示任何错误消息。@if ($errors->any())&nbsp; &nbsp; <div class="alert alert-danger">&nbsp; &nbsp; &nbsp; &nbsp; <ul>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @foreach ($errors->all() as $error)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li>{{ $error }}</li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @endforeach&nbsp; &nbsp; &nbsp; &nbsp; </ul>&nbsp; &nbsp; </div>@endif
打开App,查看更多内容
随时随地看视频慕课网APP