```ts
export function fillTemplate(template: string, values: Record<string, string>): string {
  if (typeof template !== "string") {
    throw new Error("fillTemplate expects a string template");
  }

  const placeholderRegex = /\{([a-zA-Z0-9_]+)\}/g;
  let result = "";
  let match;

  while ((match = placeholderRegex.exec(template)) !== null) {
    const placeholderName = match[1];
    if (!placeholderName || !/^[a-zA-Z0-9_]+$/.test(placeholderName)) {
      throw new Error(`Invalid placeholder name: ${placeholderName}`);
    }
    if (values.hasOwnProperty(placeholderName)) {
      result += values[placeholderName];
    } else {
      throw new Error(`Unknown placeholder: ${placeholderName}`);
    }
  }

  return result;
}
```