我在看这个问题:CakePHP 3 regex validation
我无法获得类似的功能。似乎绕过了规则:
$validator
->scalar('password')
->add('password', 'custom',[
'rule' => function ($value, $context) {
return !preg_match('/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@$.!?#]).{8,}$/i', $value);
},
'message' => 'Password must be at least 8 characters long.'
])
->maxLength('password', 255)
->requirePresence('password', 'create', 'This field is required.')
->notEmpty('password');
有人可以帮我解决我做错的事情吗?