MCPcopy Create free account
hub / github.com/angular/angular / normalizeFormArgs

Function normalizeFormArgs

packages/forms/signals/src/util/normalize_form_args.ts:18–37  ·  view source on GitHub ↗
(
  args: any[],
)

Source from the content-addressed store, hash-verified

16 * Extracts the model, schema, and options from the arguments passed to `form()`.
17 */
18export function normalizeFormArgs<TModel>(
19 args: any[],
20): [
21 WritableSignal<TModel>,
22 SchemaOrSchemaFn<TModel> | undefined,
23 (FormOptions<TModel> & {adapter?: FieldAdapter}) | undefined,
24] {
25 const model = args[0];
26 let schema: SchemaOrSchemaFn<TModel> | undefined;
27 let options: (FormOptions<TModel> & {adapter?: FieldAdapter}) | undefined;
28
29 if (isSchemaOrSchemaFn(args[1])) {
30 schema = args[1];
31 options = args[2];
32 } else {
33 options = args[1] && args[2] ? {...args[1], ...args[2]} : (args[1] ?? args[2]);
34 }
35
36 return [model, schema, options];
37}

Callers 4

constructorMethod · 0.90
compatFormFunction · 0.90
formFunction · 0.90

Calls 1

isSchemaOrSchemaFnFunction · 0.90

Tested by

no test coverage detected