$request->validate([
$request->password => 'required|min:8'
]);
Maybe I'm missing something from your example, but you should try that. There is no regex in your example.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
The docs of the regex validation says:
"Note: When using the regex pattern, it may be necessary to specify rules in an array instead of using pipe delimiters, especially if the regular expression contains a pipe character"
https://laravel.com/docs/5.5/validation#rule-regex
But it doesn't say how to specify the rules as an array. How do I pass rules to the validator as an array?
What I'm looking for is something like:
$min = 8;
$validator = Validator::make($request->all(), [
'password' => array(
'required' => true,
'min' => $min
)
]);
But that isn't working.
Please or to participate in this conversation.