MCPcopy Create free account
hub / github.com/hashintel/hash / requireSlugArg

Function requireSlugArg

apps/hash-api/src/analysis/shared/storage-key.ts:52–63  ·  view source on GitHub ↗
(
  args: Record<string, unknown>,
  key: string,
)

Source from the content-addressed store, hash-verified

50 * missing or fails validation.
51 */
52export const requireSlugArg = (
53 args: Record<string, unknown>,
54 key: string,
55): string => {
56 const value = args[key];
57 if (!isValidSlug(value)) {
58 throw new AnalysisArgError(
59 `Argument "${key}" must be a slug matching ${SLUG_PATTERN.source}`,
60 );
61 }
62 return value;
63};
64
65/** Read an optional slug argument; returns `undefined` if absent. */
66export const optionalSlugArg = (

Callers 3

supply-chain.tsFile · 0.90
optionalSlugArgFunction · 0.85

Calls 1

isValidSlugFunction · 0.85

Tested by

no test coverage detected