@@ -274,6 +274,31 @@ You can find a list of existing mime types on the `IANA website`_.
274
274
If set, the validator will check that the filename of the underlying file
275
275
doesn't exceed a certain length.
276
276
277
+ ``filenameCountUnit ``
278
+ ~~~~~~~~~~~~~~~~~~~~~
279
+
280
+ **type **: ``string `` **default **: ``File::FILENAME_COUNT_BYTES ``
281
+
282
+ The character count unit to use for the filename max length check.
283
+ By default :phpfunction: `strlen ` is used, which counts the length of the string in bytes.
284
+
285
+ Can be one of the following constants of the
286
+ :class: `Symfony\\ Component\\ Validator\\ Constraints\\ File ` class:
287
+
288
+ * ``FILENAME_COUNT_BYTES ``: Uses :phpfunction: `strlen ` counting the length of the
289
+ string in bytes.
290
+ * ``FILENAME_COUNT_CODEPOINTS ``: Uses :phpfunction: `mb_strlen ` counting the length
291
+ of the string in Unicode code points. Simple (multibyte) Unicode characters count
292
+ as 1 character, while for example ZWJ sequences of composed emojis count as
293
+ multiple characters.
294
+ * ``FILENAME_COUNT_GRAPHEMES ``: Uses :phpfunction: `grapheme_strlen ` counting the
295
+ length of the string in graphemes, i.e. even emojis and ZWJ sequences of composed
296
+ emojis count as 1 character.
297
+
298
+ .. versionadded :: 7.3
299
+
300
+ The ``filenameCountUnit `` option was introduced in Symfony 7.3.
301
+
277
302
``filenameTooLongMessage ``
278
303
~~~~~~~~~~~~~~~~~~~~~~~~~~
279
304
@@ -290,6 +315,35 @@ Parameter Description
290
315
``{{ filename_max_length }} `` Maximum number of characters allowed
291
316
============================== ==============================================================
292
317
318
+ ``filenameCharset ``
319
+ ~~~~~~~~~~~~~~~~~~~
320
+
321
+ **type **: ``string `` **default **: ``null ``
322
+
323
+ The charset to be used when computing value's filename max length with the
324
+ :phpfunction: `mb_check_encoding ` and :phpfunction: `mb_strlen `
325
+ PHP functions.
326
+
327
+ ``filenameCharsetMessage ``
328
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
329
+
330
+ **type **: ``string `` **default **: ``This filename does not match the expected charset. ``
331
+
332
+ The message that will be shown if the value is not using the given `filenameCharsetMessage `_.
333
+
334
+ You can use the following parameters in this message:
335
+
336
+ ================= ============================================================
337
+ Parameter Description
338
+ ================= ============================================================
339
+ ``{{ charset }} `` The expected charset
340
+ ``{{ name }} `` The current (invalid) value
341
+ ================= ============================================================
342
+
343
+ .. versionadded :: 7.3
344
+
345
+ The ``filenameCharset `` and ``filenameCharsetMessage `` options were introduced in Symfony 7.3.
346
+
293
347
``extensionsMessage ``
294
348
~~~~~~~~~~~~~~~~~~~~~
295
349
0 commit comments