44 lines
974 B
PHP
44 lines
974 B
PHP
<?php
|
|
|
|
|
|
|
|
|
|
namespace app\validate\admin;
|
|
|
|
use think\Validate;
|
|
|
|
class WechatNewsValidate extends Validate
|
|
{
|
|
protected $failException = true;
|
|
|
|
protected $rule = [
|
|
'data' => 'array|checkArray',
|
|
// 'title|标题' => 'require',
|
|
// 'author|作者' => 'require',
|
|
// 'synopsis|摘要' => 'require',
|
|
// 'image_input|图片' => 'require',
|
|
// 'content|内容' => 'require',
|
|
];
|
|
|
|
|
|
|
|
protected function checkArray($value,$rule,$data = [])
|
|
{
|
|
foreach ($value as $v) {
|
|
if(empty($v['title']))
|
|
return '标题不能为空';
|
|
if(empty($v['author']))
|
|
return '作者不能为空';
|
|
if(empty($v['synopsis']))
|
|
return '摘要不能为空';
|
|
if(empty($v['image_input']))
|
|
return '图片不能为空';
|
|
if(empty($v['content']))
|
|
return '内容不能为空';
|
|
}
|
|
return true;
|
|
}
|
|
|
|
|
|
}
|