( args: any[], )
| 16 | * Extracts the model, schema, and options from the arguments passed to `form()`. |
| 17 | */ |
| 18 | export 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 | } |
no test coverage detected