Skip to content

Conversation

dummdidumm
Copy link
Member

That way you can e.g. run preflight on each keystroke and full validation only on blur


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

That way you can e.g. run preflight on each keystroke and full validation only on blur
Copy link

changeset-bot bot commented Oct 17, 2025

🦋 Changeset detected

Latest commit: aeec278

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@svelte-docs-bot
Copy link

/** Set this to `true` to also show validation issues of fields that haven't been touched yet. */
includeUntouched?: boolean;
/** Set this to `true` to only run the `preflight` validation. */
clientOnly?: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this, so it's explicitly linked to .preflight(...)?

Suggested change
clientOnly?: boolean;
preflightOnly?: boolean;

@sillvva
Copy link
Contributor

sillvva commented Oct 17, 2025

What would this look like in practice?

<script>
import { form } from "$lib/remote/forms.remote.ts";
import { schema } from "$lib/schema";

function validate() {
  form.preflight(schema).validate({ preflightOnly: true }); // runs preflight schema
  form.validate(); // runs server schema
}
</script>

<form {...form}></form>

or

<script>
import { form } from "$lib/remote/forms.remote.ts";
import { schema } from "$lib/schema";

function validate() {
  form.validate(); // runs preflight schema
  form.validate({ preflightOnly: false }); // skips preflight, runs server schema
}
</script>

<form {...form.preflight(schema)}></form>

@Rich-Harris
Copy link
Member

The preflight schema would always be used. This just allows you to skip server validation. So you could for example do preflight validation on every keystroke, but additionally run server validation on change events (which are emitted when you blur an input you've been typing into, etc):

<form
  {...myform.preflight(schema)}
  oninput={() => myform.validate({ preflightOnly: true })}
  onchange={() => myform.validate()}
>...</form>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants