首页 > 解决方案 > “/”laravel消息验证问题

问题描述

我在 laravel 验证中返回正确消息时遇到问题。我的代码:

public function messages(): array
{
    return [
        'regex' => "Field :attribute is must contain alphanumeric characters . : / - , or space",
    ];
}

回复:

"Field comment is must contain alphanumeric characters . : \/ - , or space"

如何在消息中返回“/”?

标签: phplaravelvalidation

解决方案


尚不确定该消息,但您可以使用HTML entity for slash它来解决此问题,因为它会/在浏览器上正确显示。

<?php

public function messages(): array{
    return [
        'regex' => "Field :attribute is must contain alphanumeric characters . : &#47; - , or space",
    ];
}

推荐阅读