Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

638 B
Raw Blame
export function assertIdPrefix(value: string, prefix: string, label: string): string {
  if (!value) {
    throw new Error(`${label} is required.`);
  }

  if (!value.startsWith(prefix)) {
    throw new Error(`${label} must start with "${prefix}".`);
  }

  return value;
}

export function assertLimit(limit?: number): number | undefined {
  if (limit === undefined || limit === null) {
    return limit ?? undefined;
  }

  if (Number.isNaN(limit)) {
    throw new Error('Limit must be a number between 1 and 100.');
  }

  if (limit < 1 || limit > 100) {
    throw new Error('Limit must be between 1 and 100.');
  }

  return limit;
}