```ts
export function matchSetting(rules: Record<string, string>, name: string): string | null {
  if (typeof rules !== "object" || rules === null) {
    throw new Error("rules must be an object");
  }
  if (typeof name !== "string") {
    throw new Error("name must be a non-empty string");
  }
  for (const [selector, value] of Object.entries(rules)) {
    if (typeof value !== "string") {
      throw new Error(`Invalid rule value: ${value}`);
    }

    const hasStar = selector.includes("*");
    if (!hasStar) {
      if (selector === name) {
        return value;
      }
      continue;
    }

    const lastChar = selector.charAt(selector.length - 1);
    const isWildcard = selector.endsWith(".*");

    if (!isWildcard || selector !== "*") {
      throw new Error(`Invalid selector: ${selector}`);
    }

    if (name.startsWith(selector.slice(0, -2))) {
      return value;
    }
  }
  return null;
}
```