```ts
export function matchSetting(rules: Record<string, string>, name: string): string | null {
  if (typeof rules !== 'object' || typeof name !== 'string') {
    throw new Error('Invalid parameters');
  }

  for (const [selector, value] of Object.entries(rules)) {
    const regex = /^(\*|[^.]+)(\*\.*)?$/;
    const match = selector.match(regex);

    if (!match) {
      throw new Error(`Invalid selector: ${selector}`);
    }

    const [_, prefix, starPart] = match;

    if (name === '*' || name.startsWith(prefix)) {
      if (starPart && starPart !== '.*') {
        continue;
      }
      return value;
    }
  }

  return null;
}
```