Skip to content

Commit cc481f5

Browse files
committed
refactor: extract methods for password fields
1 parent 84df605 commit cc481f5

1 file changed

Lines changed: 22 additions & 12 deletions

File tree

src/Validation/ValidationRules.php

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,29 @@ public function getRegistrationRules(): array
4040
helper('setting');
4141

4242
return setting('Validation.registration') ?? [
43-
'username' => $usernameValidationRules,
44-
'email' => $emailValidationRules,
45-
'password' => [
46-
'label' => 'Auth.password',
47-
'rules' => 'required|' . Passwords::getMaxLengthRule() . '|strong_password[]',
48-
'errors' => [
49-
'max_byte' => 'Auth.errorPasswordTooLongBytes',
50-
],
51-
],
52-
'password_confirm' => [
53-
'label' => 'Auth.passwordConfirm',
54-
'rules' => 'required|matches[password]',
43+
'username' => $usernameValidationRules,
44+
'email' => $emailValidationRules,
45+
'password' => $this->getPasswordRules(),
46+
'password_confirm' => $this->getPasswordConfirmRules(),
47+
];
48+
}
49+
50+
public function getPasswordRules(): array
51+
{
52+
return [
53+
'label' => 'Auth.password',
54+
'rules' => 'required|' . Passwords::getMaxLengthRule() . '|strong_password[]',
55+
'errors' => [
56+
'max_byte' => 'Auth.errorPasswordTooLongBytes',
5557
],
5658
];
5759
}
60+
61+
public function getPasswordConfirmRules(): array
62+
{
63+
return [
64+
'label' => 'Auth.passwordConfirm',
65+
'rules' => 'required|matches[password]',
66+
];
67+
}
5868
}

0 commit comments

Comments
 (0)