Skip to content

Commit e9ad8d9

Browse files
committed
Improved warning message for null/undefined sent to superForm.
1 parent 6533f0b commit e9ad8d9

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/lib/client/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,9 @@ export function superForm<
287287
if (options.warnings?.noValidationAndConstraints !== false) {
288288
console.warn(
289289
(form
290-
? 'Form data sent directly to superForm instead of through superValidate. '
291-
: 'No form data sent to superForm. Schema type safety cannot be guaranteed. ') +
292-
'No initial validation is made and no constraints will exist for the form. ' +
290+
? 'Form data sent directly to superForm instead of through superValidate. No initial data validation is made. '
291+
: 'No form data sent to superForm, schema type safety cannot be guaranteed. ') +
292+
'Also, no constraints will exist for the form. ' +
293293
'Set the warnings.noValidationAndConstraints option to false to disable this warning.'
294294
);
295295
}

src/routes/test/+page.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,17 @@
9595
message: modalMessage,
9696
delayed: modalDelayed,
9797
enhance: modalEnhance
98+
// @ts-expect-error Set to null to test backwards compatibility, and the warning
9899
} = superForm(null, {
99100
resetForm: true,
100101
taintedMessage: null,
101102
dataType: 'json',
102103
invalidateAll: false,
103104
flashMessage: {
104105
module: flashModule
106+
},
107+
warnings: {
108+
noValidationAndConstraints: false
105109
}
106110
});
107111

0 commit comments

Comments
 (0)