@@ -149,15 +149,15 @@ public static function dataOptions(): array
149149 'parameters ' => [],
150150 ],
151151 'notExactSizeMessage ' => [
152- 'template ' => 'The size of {property} must be exactly {exactly, number} {exactly, plural, one{byte} other{bytes} }. ' ,
152+ 'template ' => 'The size of {property} must be exactly {exactly}. ' ,
153153 'parameters ' => [],
154154 ],
155155 'tooSmallMessage ' => [
156- 'template ' => 'The size of {property} cannot be smaller than {limit, number} {limit, plural, one{byte} other{bytes} }. ' ,
156+ 'template ' => 'The size of {property} cannot be smaller than {limit}. ' ,
157157 'parameters ' => [],
158158 ],
159159 'tooBigMessage ' => [
160- 'template ' => 'The size of {property} cannot be larger than {limit, number} {limit, plural, one{byte} other{bytes} }. ' ,
160+ 'template ' => 'The size of {property} cannot be larger than {limit}. ' ,
161161 'parameters ' => [],
162162 ],
163163 'unableToDetermineSizeMessage ' => [
@@ -369,6 +369,52 @@ public static function dataValidationFailed(): array
369369 new File (maxSize: 920 ),
370370 ['' => ['The size of value cannot be larger than 920 bytes. ' ]],
371371 ],
372+ 'exact size mismatch uses human-readable size ' => [
373+ self ::TEXT_FILE ,
374+ new File (size: 50 * 1024 * 1024 ),
375+ ['' => ['The size of value must be exactly 50 MB. ' ]],
376+ ],
377+ 'too small uses human-readable size ' => [
378+ self ::TEXT_FILE ,
379+ new File (minSize: 1536 ),
380+ ['' => ['The size of value cannot be smaller than 1.5 KB. ' ]],
381+ ],
382+ 'too big uses human-readable size ' => [
383+ self ::JPG_FILE ,
384+ new File (maxSize: 512 ),
385+ ['' => ['The size of value cannot be larger than 512 bytes. ' ]],
386+ ],
387+ 'size boundary rounds to next unit ' => [
388+ self ::createStreamUpload ('large.bin ' , 'application/octet-stream ' , 1024 * 1024 ),
389+ new File (maxSize: 1024 * 1024 - 1 ),
390+ ['' => ['The size of value cannot be larger than 1 MB. ' ]],
391+ ],
392+ 'custom message uses human-readable size placeholder ' => [
393+ self ::createStreamUpload ('large.bin ' , 'application/octet-stream ' , 60 * 1024 * 1024 ),
394+ new File (
395+ maxSize: 50 * 1024 * 1024 ,
396+ tooBigMessage: '{file} is larger than {limit}. ' ,
397+ ),
398+ ['' => ['large.bin is larger than 50 MB. ' ]],
399+ ],
400+ 'custom message can use raw byte size placeholder ' => [
401+ self ::JPG_FILE ,
402+ new File (
403+ maxSize: 512 ,
404+ tooBigMessage: '{file} is larger than {limit}; raw limit is {limitBytes, number} '
405+ . '{limitBytes, plural, one{byte} other{bytes}}. ' ,
406+ ),
407+ ['' => ['16x18.jpg is larger than 512 bytes; raw limit is 512 bytes. ' ]],
408+ ],
409+ 'custom exact size message can use raw byte size placeholder ' => [
410+ self ::JPG_FILE ,
411+ new File (
412+ size: 512 ,
413+ notExactSizeMessage: '{file} must be {exactly}; raw size is {exactlyBytes, number} '
414+ . '{exactlyBytes, plural, one{byte} other{bytes}}. ' ,
415+ ),
416+ ['' => ['16x18.jpg must be 512 bytes; raw size is 512 bytes. ' ]],
417+ ],
372418 'stream upload unknown exact size ' => [
373419 self ::createStreamUpload ('resume.txt ' , 'text/plain ' , null ),
374420 new File (extensions: 'txt ' , mimeTypes: 'text/plain ' , size: 22 , trustClientMediaType: true ),
0 commit comments