文档编写方式
$values = ['one', 'two', 'three'];
\Validator::make($input, ['value' => 'in:one,two,three']);
我可以使用数组设置选项吗? 现在我的做法是这样的,但我不喜欢它
\Validator::make($input, ['value' => 'in:' . implode(',', $values)]);
文档编写方式
$values = ['one', 'two', 'three'];
\Validator::make($input, ['value' => 'in:one,two,three']);
我可以使用数组设置选项吗? 现在我的做法是这样的,但我不喜欢它
\Validator::make($input, ['value' => 'in:' . implode(',', $values)]);
我认为现在使用 implode
没有其他方法。甚至使用自定义验证规则也不行。这种语法的基本问题在于
['value' => ['in' => $values]];
这是否意味着Laravel忽略了'in'
关键字,并且将$values
视为一组验证规则?
除了您不喜欢它之外,使用implode
存在问题的原因是什么?
,
的值。 - darthmaim
['value' => ['in' => $values]];
吗? - dotty