MCPcopy Index your code
hub / github.com/angular/angular / assertValidHeaders

Function assertValidHeaders

packages/common/http/src/headers.ts:282–293  ·  view source on GitHub ↗

* Verifies that the headers object has the right shape: the values * must be either strings, numbers or arrays. Throws an error if an invalid * header value is present.

(
  headers: Record<string, unknown> | Headers,
)

Source from the content-addressed store, hash-verified

280 * header value is present.
281 */
282function assertValidHeaders(
283 headers: Record<string, unknown> | Headers,
284): asserts headers is Record<string, string | string[] | number | number[]> {
285 for (const [key, value] of Object.entries(headers)) {
286 if (!(typeof value === 'string' || typeof value === 'number') && !Array.isArray(value)) {
287 throw new Error(
288 `Unexpected value of the \`${key}\` header provided. ` +
289 `Expecting either a string, a number or an array, but got: \`${value}\`.`,
290 );
291 }
292 }
293}

Callers 1

constructorMethod · 0.85

Calls 2

isArrayMethod · 0.80
entriesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…