'require', 'field' => 'require|checkField', 'value' => 'require|in:0,1', ]; protected $message = [ 'ids.require' => 'id不可为空', 'ids.number' => 'id必须为数字', 'field.require' => '参数缺失', 'value.require' => '参数缺失', 'value.in' => '参数错误', ]; /** * @notes 验证字段 * @param $value * @param $rule * @param $data * @return bool|string * @author 段誉 * @date 2022/3/17 10:40 */ public function checkField($value, $rule, $data) { $checArr = ['is_run', 'is_freeze']; if (!in_array($value, $checArr)) { return '参数错误'; } return true; } }