Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"[Error] Cannot unpack array with string keys" while using custom Validator rules in Cake 3.4.5 #10682

Closed
1 task done
animepauly opened this issue May 23, 2017 · 1 comment

Comments

@animepauly
Copy link

This is a (multiple allowed):

  • [Error] Cannot unpack array with string keys in /var/www/public/adphenom-portal/vendor/cakephp/cakephp/src/Validation/ValidationRule.php

  • CakePHP Version: 3.4.5.

What you did

When trying to register new users in our user registration form, the above error is thrown. The form consists of first name, last name, email address, password, confirm password, and birthdate fields. This worked on 3.3.x (not sure what exact version we were on before), but the form currently fails in 3.4.5.

What happened

I have pinpointed the problem to two custom validator rules in the UsersTable.php file:

$validator->add('new_password', [
            'length'=>[
                'rule'=>['minLength', 6],
                'message'=>'Password must contain at least 6 characters'
            ],
            'hasUppercase'=>[
                'rule'=>['custom', 'regex'=>'/[A-Z]/'],
                'message'=>'Password must contain at least one uppercase letter'
            ],
            'hasDigit'=>[
                'rule'=>['custom', 'regex'=>'/[0-9]/'],
                'message'=>'Password must contain at least one number'
            ]
        ]);

The 'hasUppercase' and 'hasDigit' rules are what's causing this error to be thrown.

What you expected to happen

I expect the custom validator rules to work as they did in version 3.3.x.

@markstory
Copy link
Member

Pull request up now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants