gpt4 book ai didi

php - 使用 Laravel 验证检查字符串是否为 "0"

转载 作者:行者123 更新时间:2023-12-03 11:22:05 25 4
gpt4 key购买 nike

如何在 Laravel 5.3 中检查字符串的值是否为“0”?

这是我在处理数据之前的验证规则:

// I want them to be anything but "0". So "01", "1" etc. are all okay
$rules = [
'state' => 'required',
'city' => 'required',
];

由于数据作为字符串传递,因此我不能使用 min:1 。

如果这已经被问到,我很抱歉,但我找不到答案。非常感谢!

最佳答案

这对我有用:

$rules = [
'state' => 'required|not_in:0',
'city' => 'required|not_in:0',
];

另外,看看这个:
Laravel 5.2 validation check if value is not equal to a variable

关于php - 使用 Laravel 验证检查字符串是否为 "0",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42872784/

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