Skip to content

Conversation

dummdidumm
Copy link
Member

This way when you're doing

myForm.fields.foo.set('bar')
myForm.validate();

you'll validate on the up-to-date data

closes #14630

Don't think we need a test for this.


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:.

This way when you're doing
```ts
myForm.fields.foo.set('bar')
myForm.validate();
```
you'll validate on the up-to-date data

closes #14630
Copy link

changeset-bot bot commented Oct 7, 2025

🦋 Changeset detected

Latest commit: 3fd1547

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

@Rich-Harris Rich-Harris merged commit 9e03f9e into main Oct 7, 2025
22 checks passed
@Rich-Harris Rich-Harris deleted the validate-wait-tick branch October 7, 2025 11:12
@github-actions github-actions bot mentioned this pull request Oct 7, 2025
@hyunbinseo
Copy link
Contributor

So they look like synchronous functions, but are actually async? That is magical.

@Rich-Harris
Copy link
Member

set is synchronous but results in a DOM update that happens after a microtask (because DOM updates are batched). validate is asynchronous but you don't need to await it, it'll just update issues whenever it resolves

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.

Programmatic preflight validate() after setting form inputs
3 participants