```ts
export function matchSetting(rules: Record<string, string>, name: string): string | null {
  if (typeof name !== 'string' || name === '' || name.includes('*')) throw new Error('Invalid name');
  for (const [selector, value] of Object.entries(rules)) {
    if (selector === name) return value;
    if (selector.endsWith('.*') && name.startsWith(selector.slice(0, -2))) return value;
  }
  return null;
}
```