Skip to content

Conversation

@Rich-Harris
Copy link
Member

I was playing around with #14624 locally and it's pretty dang cool. But it occurs to me that most of the time, when you use invalid(...) it will be with a single error, and often it'll be a root-level error. If we optimise for those two facts a slightly different API suggests itself — instead of invalid([issue]), we can do invalid(issue), and instead of invalid.$(...) we can just accept strings.

So this...

invalid([
  invalid.$(error.message)
]);

...would become this:

invalid(error.message);

@changeset-bot
Copy link

changeset-bot bot commented Oct 7, 2025

⚠️ No Changeset found

Latest commit: 1da094f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@dummdidumm dummdidumm merged commit 9aaaf72 into imperative-form-validation Oct 7, 2025
34 of 35 checks passed
@dummdidumm dummdidumm deleted the imperative-form-validation-tweaks branch October 7, 2025 08:07
Rich-Harris added a commit that referenced this pull request Oct 7, 2025
* feat: imperative form validation

Not all validation can happen via the schema, this introduces a way to do it imperatively

* fix

* Apply suggestion from @Rich-Harris

Co-authored-by: Rich Harris <richard.a.harris@gmail.com>

* Apply suggestion from @Rich-Harris

Co-authored-by: Rich Harris <richard.a.harris@gmail.com>

* tweak `invalid(...)` API (#14625)

* Apply suggestions from code review

---------

Co-authored-by: Rich Harris <richard.a.harris@gmail.com>
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.

2 participants