'require|length:1,50', // 'tid|模板' => 'require|gt:0', 'type|类型' => 'require|in:1,2,3', ]; protected $message = [ 'tid.require' => '未选择模板', 'tid.gt' => '未选择模板', ]; protected function checkContent($value,$rule,$data=[]) { if(!$data['content']){ return '模块绑定不能为空'; } $content = json_decode($data['content'],true); if(empty($content)){ return '模块绑定不能为空'; } foreach ($content as $k=>$v){ if($v['mid'] == 0){ return '未选择模块'; } } return true; } }