@@ -12,7 +12,7 @@ class UploadedFile extends Rule implements BeforeValidate
1212 use Traits \FileTrait, Traits \SizeTrait;
1313
1414 /** @var string */
15- protected $ message = "The :attribute is not valid " ;
15+ protected $ message = "The :attribute is not valid uploaded file " ;
1616
1717 /** @var string|int */
1818 protected $ maxSize = null ;
@@ -133,6 +133,11 @@ public function check($value): bool
133133 $ maxSize = $ this ->parameter ('max_size ' );
134134 $ allowedTypes = $ this ->parameter ('allowed_types ' );
135135
136+ if ($ allowedTypes ) {
137+ $ or = $ this ->validation ? $ this ->validation ->getTranslation ('or ' ) : 'or ' ;
138+ $ this ->setParameterText ('allowed_types ' , Helper::join (Helper::wraps ($ allowedTypes , "' " ), ', ' , ", {$ or } " ));
139+ }
140+
136141 // below is Required rule job
137142 if (!$ this ->isValueFromUploadedFiles ($ value ) or $ value ['error ' ] == UPLOAD_ERR_NO_FILE ) {
138143 return true ;
@@ -150,13 +155,15 @@ public function check($value): bool
150155 if ($ minSize ) {
151156 $ bytesMinSize = $ this ->getBytesSize ($ minSize );
152157 if ($ value ['size ' ] < $ bytesMinSize ) {
158+ $ this ->setMessage ('The :attribute file is too small, minimum size is :min_size ' );
153159 return false ;
154160 }
155161 }
156162
157163 if ($ maxSize ) {
158164 $ bytesMaxSize = $ this ->getBytesSize ($ maxSize );
159165 if ($ value ['size ' ] > $ bytesMaxSize ) {
166+ $ this ->setMessage ('The :attribute file is too large, maximum size is :max_size ' );
160167 return false ;
161168 }
162169 }
@@ -167,6 +174,7 @@ public function check($value): bool
167174 unset($ guesser );
168175
169176 if (!in_array ($ ext , $ allowedTypes )) {
177+ $ this ->setMessage ('The :attribute file type must be :allowed_types ' );
170178 return false ;
171179 }
172180 }
0 commit comments