modxcms/Login

Validator name has new line and cannot be find

Closed this issue · 2 comments

modx 2.8.3
fenom

Register call:

{'!Register' | snippet : [
     ...
    'customValidators' => 'someSnippet',
    'validate' => '
        email:email,
        name:someSnippet
    ',
    'placeholderPrefix' => 'leg.'
]}

var_dump in loginvalidator.class.php::validate
and i get
string(4) "name"
string(4) "test"
string(13) "someSnippet
"<-- here new line

how i fix:
add trim in loginvalidator.class.php::_validate
$this->validate($key[0],$v,trim($key[$i]));
$this->validate($k,$v,trim($validator));

Jako commented

You maybe have to remove the new line after the last validator, since this will trigger a new empty validator.

But please check wether the code in https://github.com/modxcms/Login/blob/master/core/components/login/model/login/loginvalidator.class.php#L99 can be changed to

if (!empty(trim($key[0]))) {

to solve your issue.

Jako commented

Closed due to lack of response. Please reopen the issue if it is still valid.