Skip to content

feat: Add isValid to Remote Form - #16080

Closed
Kynson wants to merge 5 commits into
sveltejs:mainfrom
Kynson:main
Closed

Kynson wants to merge 5 commits into
sveltejs:mainfrom
Kynson:main

Conversation

@Kynson

@Kynson Kynson commented Jun 18, 2026 •

Copy link
Copy Markdown

closes #16032

Goal

Adds a isValid property to remote form and fields. This makes it easier to dynamically react to the validity of the fields and the form with less boilerplate.

Reason for this feature

It requires some boilerplate to check if a form is valid:

const isValid = $derived(!form.fields.allIssues())

Or for a field

const isValid = $derived(!form.fields.group.allIssues())

Changes made

  1. Added a isValid property in RemoteForm. Defaults to true. Refresh when validate is called.
  2. Added a isValid property in the fields proxy (via create_field_proxy), enables users to check if a group of fields are valid easily.

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

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

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

@changeset-bot

changeset-bot Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: aba2668

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 Minor

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

@Kynson Kynson changed the title Add isValid to Remote Form feat: Add isValid to Remote Form Jun 19, 2026
@Rich-Harris

Copy link
Copy Markdown
Member

I'm 👎 on this change, personally — I don't see this...

myform.fields.foo.isValid()

...as a particularly meaningful improvement over this:

!myform.fields.foo.issues()

It's additional surface area that doesn't add any new capability, and it's not 100% obvious whether it's the opposite of issues or allIssues, in the cases where that matters.

myform.isValid() is slightly more compelling, but only slightly. I'll leave this open for now for others to weigh in but I don't think it's worth it.

@Kynson

Kynson commented Jun 23, 2026

Copy link
Copy Markdown
Author

@Rich-Harris I get your point, then let's see what others think then. Any other feedback on how to improve this are welcome. Thanks.

PS: One personal, not technical, reason why I suggest this is I found myself instinctively try to look for a isValid or something similar when building with remote functions. Negating issues or allIssues is not the first thing that come to my mind. Still, I think your point of adding this feature introduces ambiguity is equally valid.

@teemingc

Copy link
Copy Markdown
Member

Agree with Rich that we don’t need this. If anything, we should just document this pattern explicitly. I checked the documentation and there isn’t an example with ! .allIssues()

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.

Expose an isValid Field for Remote Form

3 participants