Created
April 9, 2017 07:22
-
-
Save hissy/9cd16ec05b0c988a915167df6bd11ded to your computer and use it in GitHub Desktop.
[concrete5] [V8] Add password validation rule
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// application/bootstrap/app.php | |
/** @var \Concrete\Core\Validator\ValidatorManagerInterface $passwordValidator */ | |
$passwordValidator = Core::make('validator/password'); | |
/** @var \Concrete\Core\Validator\String\RegexValidator $regexValidator */ | |
$regexValidator = Core::make( | |
\Concrete\Core\Validator\String\RegexValidator::class, | |
['/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).+$/'] | |
); | |
$regexValidator->setRequirementString( | |
\Concrete\Core\Validator\String\RegexValidator::E_DOES_NOT_MATCH, | |
t('The password must include upper and lower case letters, numbers.') | |
); | |
$regexValidator->setErrorString( | |
\Concrete\Core\Validator\String\RegexValidator::E_DOES_NOT_MATCH, | |
t('The password must include upper and lower case letters, numbers.') | |
); | |
$passwordValidator->setValidator('character_types', $regexValidator); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment