MCPcopy Create free account
hub / github.com/angular/dev-infra / assertValidFormatConfig

Function assertValidFormatConfig

ng-dev/format/config.ts:17–34  ·  view source on GitHub ↗
(
  config: T & Partial<{format: FormatConfig}>,
)

Source from the content-addressed store, hash-verified

15
16/** Retrieve and validate the config as `FormatConfig`. */
17export function assertValidFormatConfig<T extends NgDevConfig>(
18 config: T & Partial<{format: FormatConfig}>,
19): asserts config is T & {format: FormatConfig} {
20 // List of errors encountered validating the config.
21 const errors: string[] = [];
22 if (config.format === undefined) {
23 throw new ConfigValidationError(`No configuration defined for "format"`);
24 }
25
26 for (const [key, value] of Object.entries(config.format!)) {
27 if (typeof value !== 'boolean') {
28 errors.push(`"format.${key}" is not a boolean`);
29 }
30 }
31 if (errors.length) {
32 throw new ConfigValidationError('Invalid "format" configuration', errors);
33 }
34}

Callers 3

checkValidityFunction · 0.90
getActiveFormattersFunction · 0.85

Calls 2

entriesMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected