|
5 | 5 | namespace F9Web\ValidationRules\Rules;
|
6 | 6 |
|
7 | 7 | use F9Web\ValidationRules\Rule;
|
| 8 | + |
8 | 9 | use function __;
|
9 | 10 | use function mb_strlen;
|
10 | 11 | use function preg_match_all;
|
@@ -38,24 +39,31 @@ public function passes($attribute, $value): bool
|
38 | 39 | {
|
39 | 40 | $this->setAttribute($attribute);
|
40 | 41 |
|
41 |
| - $containsUppercase = '/[A-Z]/'; |
42 |
| - $containsLowercase = '/[a-z]/'; |
43 |
| - $specialCharacters = '/['.$this->specialCharacters.']/'; |
44 |
| - $numbers = '/[0-9]/'; |
45 |
| - |
46 |
| - if ($this->mustIncludeUppercaseCharacters && preg_match_all($containsUppercase, $value, $o) === 0) { |
| 42 | + if ( |
| 43 | + $this->mustIncludeUppercaseCharacters && |
| 44 | + preg_match_all('/[A-Z]/', $value, $o) === 0 |
| 45 | + ) { |
47 | 46 | return false;
|
48 | 47 | }
|
49 | 48 |
|
50 |
| - if ($this->mustIncludeLowercaseCharacters && preg_match_all($containsLowercase, $value, $o) === 0) { |
| 49 | + if ( |
| 50 | + $this->mustIncludeLowercaseCharacters && |
| 51 | + preg_match_all('/[a-z]/', $value, $o) === 0 |
| 52 | + ) { |
51 | 53 | return false;
|
52 | 54 | }
|
53 | 55 |
|
54 |
| - if ($this->mustIncludeSpecialCharacters && preg_match_all($specialCharacters, $value, $o) === 0) { |
| 56 | + if ( |
| 57 | + $this->mustIncludeSpecialCharacters && |
| 58 | + preg_match_all('/['.$this->specialCharacters.']/', $value, $o) === 0 |
| 59 | + ) { |
55 | 60 | return false;
|
56 | 61 | }
|
57 | 62 |
|
58 |
| - if ($this->mustIncludeNumbers && preg_match_all($numbers, $value, $o) === 0) { |
| 63 | + if ( |
| 64 | + $this->mustIncludeNumbers && |
| 65 | + preg_match_all('/[0-9]/', $value, $o) === 0 |
| 66 | + ) { |
59 | 67 | return false;
|
60 | 68 | }
|
61 | 69 |
|
@@ -153,6 +161,8 @@ public function message(): string
|
153 | 161 | {
|
154 | 162 | $key = 'f9web-validation-rules::messages.'.$this->getMessageKey();
|
155 | 163 |
|
| 164 | + $message = []; |
| 165 | + |
156 | 166 | $message[] = __(
|
157 | 167 | $key.'.base',
|
158 | 168 | [
|
|
0 commit comments