gpt4 book ai didi

php - 如何检查 Laravel 5.2 验证中的特定错误?

转载 作者:行者123 更新时间:2023-12-04 17:48:18 25 4
gpt4 key购买 nike

现在,我可以使用以下方法检查 blade 中是否存在验证错误的字段:

@if($errors->has('field_name'))
<div class="help-block">
Lorem Ipsum
</div>
@endif

在我的 Controller 中,我使用了 not_in 规则:

"field_name"=> "required|string|not_in:

我想知道,我可以更改 if 语句以仅检查 not_in 规则吗?

示例:

@if($errors->has('field_name.not_in'))

最佳答案

@if($errors->has('field_name') and $errors->first('field_name') == 'The selected field_name is invalid.')
this is just for not in validation for special input.
@endif

关于php - 如何检查 Laravel 5.2 验证中的特定错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47168411/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com