function getDefaultMessage() { $settings = $this->validator->getSettingsForJS(); $message = []; $label = $this->field->Title(); if (isset($settings['minimumChars'])) { $message[] = _t('ValidPassword.DESC-PASSWORD_MINIMUM_CHARACTERS', '{field} must be at least {min} characters.', ['field' => $label, 'min' => $settings['minimumChars']]); } if (isset($settings['minimumScore'])) { $message[] = _t('ValidPassword.DESC-PASSWORD_MINIMUM_SCORE', '{field} must pass at least {score} of the following requirements: ', ['field' => $label, 'score' => $settings['minimumScore']]); } if (isset($settings['tests'])) { $tests = array(); if (in_array('lowercase', $settings['tests'])) { $tests[] = _t('ValidPassword.ONE_LOWERCASE_LETTER', 'one lowercase letter'); } if (in_array('uppercase', $settings['tests'])) { $tests[] = _t('ValidPassword.ONE_UPPERCASE_LETTER', 'one uppercase letter'); } if (in_array('digits', $settings['tests'])) { $tests[] = _t('ValidPassword.ONE_NUMBER', 'one number'); } if (in_array('punctuation', $settings['tests'])) { $tests[] = _t('ValidPassword.ONE_SYMBOL', 'one symbol'); } if (count($tests)) { if (count($tests) > 1) { $lastTest = array_pop($tests); $test = implode(', ', $tests) . ' ' . _t('AND', 'and') . ' ' . $lastTest; } else { $test = array_pop($tests); } $message[] = _t('ValidPassword.DESC-PASSWORD_REQUIREMENTS', '{field} should have at least {tests}.', ['field' => $label, 'tests' => $test]); } } return implode(' ', $message); }