I have a User form class which has elements and I am trying to add Regex validator.
Here is what I have tried
$inputFilter->add([
"name" => "password",
"required" => true,
"filters" => [
],
"validators" => [
[
"name" => new Regex(["pattern" => "/^[a-zA-Z0-9_]+$/"]),
],
[
"name" => "NotEmpty",
],
[
"name" => "StringLength",
"options" => [
"min" => 6,
"max" => 64
],
],
],
]);
But it throws
Object of class Zend\Validator\Regex could not be converted to string
Can anyone help me out?