|
@@ -169,12 +169,12 @@ class Verify { |
|
@@ -169,12 +169,12 @@ class Verify { |
169
|
/**
|
169
|
/**
|
170
|
* 必须
|
170
|
* 必须
|
171
|
* @param $key
|
171
|
* @param $key
|
172
|
- * @return false
|
172
|
+ * @return bool
|
173
|
* @author:dc
|
173
|
* @author:dc
|
174
|
- * @time 2023/3/13 10:11
|
174
|
+ * @time 2023/3/13 17:14
|
175
|
*/
|
175
|
*/
|
176
|
public function required($key){
|
176
|
public function required($key){
|
177
|
- return $this->_get($key) !== '';
|
177
|
+ return $this->_get($key) !== '' || app()->file($key);
|
178
|
}
|
178
|
}
|
179
|
|
179
|
|
180
|
|
180
|
|
|
@@ -388,7 +388,37 @@ class Verify { |
|
@@ -388,7 +388,37 @@ class Verify { |
388
|
* @time 2023/3/13 14:27
|
388
|
* @time 2023/3/13 14:27
|
389
|
*/
|
389
|
*/
|
390
|
public function file($key,$value){
|
390
|
public function file($key,$value){
|
|
|
391
|
+ $files = app()->file($key);
|
|
|
392
|
+ if($files){
|
|
|
393
|
+ foreach ($files as $file){
|
|
|
394
|
+ // 后缀
|
|
|
395
|
+ if(!empty($value['ext'])){
|
|
|
396
|
+ $value['ext'] = is_string($value['ext']) ? [$value['ext']] : [];
|
|
|
397
|
+ if (!in_array($file->ext,$value['ext'])){
|
|
|
398
|
+ app()->e(['verify_file.ext',[$this->alias[$key],$file->name,implode('|',$value['ext'])]],600);
|
|
|
399
|
+ return false;
|
|
|
400
|
+ }
|
|
|
401
|
+ }
|
391
|
|
402
|
|
|
|
403
|
+ // 类型
|
|
|
404
|
+ if(!empty($value['mine'])){
|
|
|
405
|
+ $value['mine'] = is_string($value['mine']) ? [$value['mine']] : [];
|
|
|
406
|
+ if (!in_array($file->mime,$value['mine'])){
|
|
|
407
|
+ app()->e(['verify_file.mine',[$this->alias[$key],$file->name,implode('|',$value['mine'])]],600);
|
|
|
408
|
+ return false;
|
|
|
409
|
+ }
|
|
|
410
|
+ }
|
|
|
411
|
+
|
|
|
412
|
+ // 大小
|
|
|
413
|
+ if(!empty($value['size'])){
|
|
|
414
|
+ if ($file->size > $value['size']){
|
|
|
415
|
+ app()->e(['verify_file.size',[$this->alias[$key],$file->name,$value['size']]],600);
|
|
|
416
|
+ return false;
|
|
|
417
|
+ }
|
|
|
418
|
+ }
|
|
|
419
|
+ }
|
|
|
420
|
+ }
|
|
|
421
|
+ return true;
|
392
|
}
|
422
|
}
|
393
|
|
423
|
|
394
|
|
424
|
|