3

文档方式

$values = ['one', 'two', 'three'];
\Validator::make($input, ['value' => 'in:one,two,three']);

我可以用数组设置选项吗?现在我这样用,我不喜欢

\Validator::make($input, ['value' => 'in:' . implode(',', $values)]);
4

1 回答 1

0

I don't think there's another way than using implode like you do now. Not even with a custom validation rule. The essential problem with a syntax like this

['value' => ['in' => $values]];

is that Laravel just ignores the 'in' key and thinks $values are a set of validation rules.

Is there a reason why using implode is a problem? (other than you don't liking it)

于 2015-02-19T21:17:36.877 回答