'require|unique:sys_schedule|checkKeyType', ]; protected $message = [ 'key.require' => 'validate_schedule.schedule_require', 'key.unique' => 'validate_schedule.schedule_unique', ]; protected $scene = [ 'add' => ['key'], 'edit' => [], ]; /** * 自定义验证 任务类型 * @param $value * @param $rule * @param array $data * @return Lang|true */ protected function checkKeyType($value, $rule, $data = []) { $temp = array_column((new CoreScheduleService())->getTemplateList(), null, 'key'); return isset($temp[$value]) ? true : get_lang("validate_schedule.not_exit_schedule_type"); } }