$group(); if (! isset($groupRules[$key])) { throw new \Exception(sprintf("The %s configuration field under the %s group is not supported", $key, $group)); } $result = validator([$key => $value], [$key => $groupRules[$key]]); if ($result->fails()) { throw new \Exception($result->errors()->first()); } } /** * email 字段验证 * * @return string[] */ private function email(): array { return [ "email_notification" => "in:on,off", "async_sender" => "in:yes,no", "sender_email" => "nullable|email", "sender" => "nullable|min:1", "domain" => "nullable|url", "smtp_server" => "nullable|min:1", "smtp_account" => "nullable|min:1", "smtp_validation" => "in:yes,no", "smtp_port" => "nullable|numeric", "encryption" => "in:ssl,plain,tls", "smtp_password" => "nullable|min:6", "debug" => "in:off,normal,high", "charset" => "in:utf8,gbk" ]; } }