Documentation way
$values = ['one', 'two', 'three'];
\Validator::make($input, ['value' => 'in:one,two,three']);
Can I set in options with array? Now I use it like that, and I don't like it
\Validator::make($input, ['value' => 'in:' . implode(',', $values)]);
1 Answer 1
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)
answered Feb 19, 2015 at 21:17
lukasgeiter
154k29 gold badges350 silver badges279 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
darthmaim
One problem could be values containing
,.lang-php
['value' => ['in' => $values]];?