非常基本的问题,我正在尝试为Laravel中的正则表达式验证规则自定义错误消息.特定的规则是密码,并要求密码有6-20个字符,至少一个数字和一个大写和小写字母,所以我想与用户沟通,而不是只是默认的消息,说格式为“无效”.
1)
'custom' => array( 'password.regex:' => 'Password must contain at least one number and both uppercase and lowercase letters.' )
2)
'custom' => array( 'password.regex' => 'Password must contain at least one number and both uppercase and lowercase letters.' )
3)
'custom' => array( 'password.regex:((?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,20})' => 'Password must contain at least one number and both uppercase and lowercase letters.' )
这些都没有奏效.有没有办法做到这一点?