File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Test/Unit/Model/Attribute/Data Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,9 @@ public function validateValue($value)
79
79
return $ errors ;
80
80
}
81
81
82
+ // if string with diacritics encode it.
83
+ $ value = $ this ->encodeDiacritics ($ value );
84
+
82
85
$ validateLengthResult = $ this ->validateLength ($ attribute , $ value );
83
86
$ errors = array_merge ($ errors , $ validateLengthResult );
84
87
@@ -173,4 +176,19 @@ private function validateInputRule(string $value): array
173
176
$ result = $ this ->_validateInputRule ($ value );
174
177
return \is_array ($ result ) ? $ result : [];
175
178
}
179
+
180
+ /**
181
+ * Encode strings with diacritics for validate.
182
+ *
183
+ * @param array|string $value
184
+ * @return array|string
185
+ */
186
+ private function encodeDiacritics ($ value ): array |string
187
+ {
188
+ $ encoded = $ value ;
189
+ if (is_string ($ value )) {
190
+ $ encoded = iconv ('UTF-8 ' , 'ASCII//TRANSLIT//IGNORE ' , $ value );
191
+ }
192
+ return $ encoded ;
193
+ }
176
194
}
Original file line number Diff line number Diff line change @@ -199,6 +199,16 @@ public function alphanumWithSpacesDataProvider(): array
199
199
];
200
200
}
201
201
202
+ /**
203
+ * Test for string with diacritics validation
204
+ */
205
+ public function testValidateValueStringWithDiacritics (): void
206
+ {
207
+ $ inputValue = "á â à å ä ð é ê è ë í î ì ï ó ô ò ø õ ö ú û ù ü æ œ ç ß a ĝ ń ŕ ý ð ñ " ;
208
+ $ expectedResult = true ;
209
+ self ::assertEquals ($ expectedResult , $ this ->model ->validateValue ($ inputValue ));
210
+ }
211
+
202
212
/**
203
213
* @param array $attributeData
204
214
* @return Attribute
You can’t perform that action at this time.
0 commit comments