Laravel阵列验证不显示错误消息

时间:2019-07-01 09:56:40

标签: php arrays string laravel validation

首先,我可以说搜索后没有找到任何解决方案。我像这样的帖子做验证数组: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',
    ]

它们说和它们都不说的都是字符串数组。在迁移中,我有两个字段(文本),例如1000个字符的字符串。

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

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

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

我在做什么错了?

enter image description here

enter image description here

最诚挚的问候

2 个答案:

答案 0 :(得分:1)

'YOUR_FIELD' => '...|...|max:1000| ...'

有关更多信息,请查看Laravel验证docs

答案 1 :(得分:-2)

请在刀片文件中放置以下代码,以显示任何错误消息。

<tr>
    <th>ID</th>
    <th>Marker</th>
    <th>Objek</th>
    <th>Action</th>
</tr>
</thead>
<tbody>
    <tr>
        <td>
            <?php  foreach( $data['id']->results as $row) { ?> 
                <td>
                <?php print_r($row[0]); ?>
                </td>
            <?php } ?>
        </td>
        <td>Decker</td>
        <td>Regional Director</td>
        <td>Edinburgh</td>
    </tr>
</tbody>
相关问题