Skip to content

Commit 96f1f06

Browse files
committed
[sveltekit] Remove computeDefaults option from initForm
1 parent ea086e5 commit 96f1f06

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

packages/sveltekit/src/lib/server/server.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import {
44
DEFAULT_ID_PREFIX,
55
DEFAULT_ID_SEPARATOR,
66
DEFAULT_PSEUDO_ID_SEPARATOR,
7-
DefaultFormMerger,
8-
type FormMerger,
97
type FormValidator,
108
type Schema,
119
type SchemaValue,
@@ -22,29 +20,21 @@ export interface InitFormOptions<T, E, SendSchema extends boolean> {
2220
schema: Schema;
2321
validator: FormValidator<E>;
2422
sendSchema?: SendSchema;
25-
merger?: FormMerger;
2623
initialValue?: T;
27-
/** @default true */
28-
computeDefaults?: boolean;
2924
/** @default false */
3025
performValidation?: boolean;
3126
}
3227

3328
export function initForm<T, E, SendSchema extends boolean = false>({
3429
schema,
3530
validator,
36-
merger = new DefaultFormMerger(validator, schema),
3731
initialValue,
38-
computeDefaults = true,
3932
performValidation = false,
4033
sendSchema
4134
}: InitFormOptions<T, E, SendSchema>): InitialFormData<T, E, SendSchema> {
42-
const defaultedData = computeDefaults
43-
? merger.mergeFormDataAndSchemaDefaults(initialValue as SchemaValue | undefined, schema)
44-
: (initialValue as SchemaValue | undefined);
45-
const errors = performValidation ? validator.validateFormData(schema, defaultedData) : [];
35+
const errors = performValidation ? validator.validateFormData(schema, initialValue as SchemaValue | undefined) : [];
4636
return {
47-
initialValue: defaultedData as T | undefined,
37+
initialValue,
4838
initialErrors: errors,
4939
schema: (sendSchema ? schema : undefined) as SendSchema extends true ? Schema : undefined
5040
};

0 commit comments

Comments
 (0)