Function

sanitizeFormConfig

@ng-forge/dynamic-forms

Walk a FormConfig, validate every field's addons against the active FIELD_REGISTRY">FIELD_REGISTRY and ADDON_KIND_REGISTRY">ADDON_KIND_REGISTRY, and return a sanitized copy plus a list of dropped-addon warnings.

Distinct from the INTERNAL validateFormConfig in utils/config-validation/config-validator.ts (which throws on structural errors like duplicate keys / unknown field types). This helper is the PUBLIC, lenient addon-shape pass — renamed to sanitizeFormConfig to avoid the name collision.

Lenient by design: invalid addons are dropped (with warnings) rather than thrown. The form keeps rendering even when the backend ships an addon the FE doesn't understand.

<df-dynamic-form> already runs this internally at form init — calling the public helper AND passing the original config to the form will double-emit warnings. Use this entry point only when you need the sanitized config or warning list outside the form (e.g., admin-UI diagnostics, build-time lints).

Must be called within an Angular injection context — typically inside an admin-UI component or a runInInjectionContext() block on the server.

Signature

function sanitizeFormConfig(
  config: FormConfig<RegisteredFieldTypes[], { [x: string]: string | number | boolean | (string | number | boolean)[]; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: Record<string, unknown>; } & { [x: string]: string[] | (string | number | boolean | (string | number | boolean)[])[] | number[] | string[] | string[] | boolean[] | string[] | string[] | string[] | string[] | string[] | string[] | string[] | string[] | string[] | string[] | string[] | string[] | string[] | string[] | number[] | boolean[] | string[] | string[] | string[] | ({ [x: string]: string | number | boolean | (string | number | boolean)[]; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: Record<string, unknown>; } & { [x: string]: string | undefined; })[]; } & { [x: string]: unknown[]; } & { [x: string]: string[] | (string | number | boolean | (string | number | boolean)[])[] | number[] | string[] | string[] | boolean[] | string[] | string[] | string[] | string[] | string[] | string[] | string[] | string[] | string[] | string[] | string[] | string[] | string[] | string[] | number[] | boolean[] | string[] | string[] | string[] | ({ [x: string]: string | number | boolean | (string | number | boolean)[]; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: Record<string, unknown>; } & { [x: string]: string | undefined; })[]; } & { [x: string]: string | undefined; } & { [x: string]: unknown[]; } & { [x: string]: string | undefined; }, Record<string, unknown>, unknown>,
  options?: SanitizeFormConfigOptions = {}
): SanitizedFormConfig

Parameters

NameTypeDescription
configFormConfig<RegisteredFieldTypes[], { [x: string]: string | number | boolean | (string | number | boolean)[]; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefined; } & { [x: string]: string | undefin...-
options?SanitizeFormConfigOptions-

Returns

SanitizedFormConfig

Examples

```typescript