77 * @package Mage_Customer
88 */
99
10+ use Symfony \Component \Validator \ConstraintViolationListInterface ;
11+
1012/**
1113 * Customer model
1214 *
@@ -1096,26 +1098,11 @@ public function validate()
10961098 message: Mage::helper ('customer ' )->__ ('Invalid email address "%s". ' , $ email ),
10971099 ));
10981100
1099- $ password = $ this ->getPassword ();
1100- $ minPasswordLength = $ this ->getMinPasswordLength ();
1101+ $ violations ->append ($ this ->getPasswordValidator (value: $ this ->getPassword ()));
11011102
1102- $ violations ->append ($ validator ->validateNotEmpty (
1103- value: $ password ,
1104- message: Mage::helper ('customer ' )->__ ('The password cannot be empty. ' ),
1105- ));
1106-
1107- $ violations ->append ($ validator ->validateLength (
1108- value: $ password ,
1109- min: $ minPasswordLength ,
1110- max: self ::MAXIMUM_PASSWORD_LENGTH ,
1111- minMessage: Mage::helper ('customer ' )->__ ('The minimum password length is %s ' , $ minPasswordLength ),
1112- maxMessage: Mage::helper ('customer ' )->__ ('Please enter a password with at most %s characters. ' , self ::MAXIMUM_PASSWORD_LENGTH ),
1113- ));
1114-
1115- $ confirmation = $ this ->getPasswordConfirmation ();
11161103 $ violations ->append ($ validator ->validateIdentical (
1117- value: $ confirmation ,
1118- compare: $ password ,
1104+ value: $ this -> getPasswordConfirmation () ,
1105+ compare: $ this -> getPassword () ,
11191106 message: Mage::helper ('customer ' )->__ ('Please make sure your passwords match. ' ),
11201107 ));
11211108
@@ -1159,25 +1146,11 @@ public function validateResetPassword()
11591146 $ validator = $ this ->getValidationHelper ();
11601147 $ violations = new ArrayObject ();
11611148
1162- $ password = $ this ->getPassword ();
1163- $ minPasswordLength = $ this ->getMinPasswordLength ();
1164-
1165- $ violations ->append ($ validator ->validateNotEmpty (
1166- value: $ password ,
1167- message: Mage::helper ('customer ' )->__ ('The password cannot be empty. ' ),
1168- ));
1169-
1170- $ violations ->append ($ validator ->validateLength (
1171- value: $ password ,
1172- min: $ minPasswordLength ,
1173- max: self ::MAXIMUM_PASSWORD_LENGTH ,
1174- minMessage: Mage::helper ('customer ' )->__ ('The minimum password length is %s ' , $ minPasswordLength ),
1175- maxMessage: Mage::helper ('customer ' )->__ ('Please enter a password with at most %s characters. ' , self ::MAXIMUM_PASSWORD_LENGTH ),
1176- ));
1149+ $ violations ->append ($ this ->getPasswordValidator (value: $ this ->getPassword ()));
11771150
11781151 $ violations ->append ($ validator ->validateIdentical (
11791152 value: $ this ->getPasswordConfirmation (),
1180- compare: $ password ,
1153+ compare: $ this -> getPassword () ,
11811154 message: Mage::helper ('customer ' )->__ ('Please make sure your passwords match. ' ),
11821155 ));
11831156
@@ -1189,6 +1162,21 @@ public function validateResetPassword()
11891162 return (array ) $ errors ;
11901163 }
11911164
1165+ public function getPasswordValidator (mixed $ value ): ConstraintViolationListInterface
1166+ {
1167+ $ min = $ this ->getMinPasswordLength ();
1168+ $ validator = $ this ->getValidationHelper ();
1169+
1170+ return $ validator ->validatePassword (
1171+ value: $ value ,
1172+ min: $ min ,
1173+ max: self ::MAXIMUM_PASSWORD_LENGTH ,
1174+ emptyMessage: Mage::helper ('customer ' )->__ ('The password cannot be empty. ' ),
1175+ minMessage: Mage::helper ('customer ' )->__ ('The minimum password length is %s ' , $ min ),
1176+ maxMessage: Mage::helper ('customer ' )->__ ('Please enter a password with at most %s characters. ' , self ::MAXIMUM_PASSWORD_LENGTH ),
1177+ );
1178+ }
1179+
11921180 /**
11931181 * Import customer data from text array
11941182 *
0 commit comments