From 9c0e25503c9530f3ec1225c201c3e5916b4cc22e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 1 Jan 2026 19:00:31 +0000 Subject: [PATCH 1/6] Initial plan From ec648a4677141ce97d43e4ff8d92ab129c26c65c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 1 Jan 2026 19:05:42 +0000 Subject: [PATCH 2/6] docs: fix invalid() documentation to reflect actual API Co-authored-by: teemingc <54401897+teemingc@users.noreply.github.com> --- documentation/docs/20-core-concepts/60-remote-functions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/docs/20-core-concepts/60-remote-functions.md b/documentation/docs/20-core-concepts/60-remote-functions.md index 6bdc4e30d779..d12c454001b7 100644 --- a/documentation/docs/20-core-concepts/60-remote-functions.md +++ b/documentation/docs/20-core-concepts/60-remote-functions.md @@ -484,11 +484,11 @@ export const buyHotcakes = form( ); ``` -The `invalid` function works as both a function and a proxy: +The `invalid` function throws a validation error with the provided issues: - Call `invalid(issue1, issue2, ...issueN)` to throw a validation error - If an issue is a `string`, it applies to the form as a whole (and will show up in `fields.allIssues()`) -- Use `invalid.fieldName(message)` to create an issue for a specific field. Like `fields` this is type-safe and you can use regular property access syntax to create issues for deeply nested objects (e.g. `invalid.profile.email('Email already exists')` or `invalid.items[0].qty('Insufficient stock')`) +- Use the `issue` parameter (provided by the form callback) to create issues for specific fields. It is type-safe and you can use regular property access syntax to create issues for deeply nested objects (e.g. `issue.profile.email('Email already exists')` or `issue.items[0].qty('Insufficient stock')`) ### Validation From b74063eeb860395b5f0c8c0f9ccaa6236b33b03e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 1 Jan 2026 19:09:05 +0000 Subject: [PATCH 3/6] docs: add changeset for invalid() documentation fix Co-authored-by: teemingc <54401897+teemingc@users.noreply.github.com> --- .changeset/brown-impalas-judge.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/brown-impalas-judge.md diff --git a/.changeset/brown-impalas-judge.md b/.changeset/brown-impalas-judge.md new file mode 100644 index 000000000000..7d8f0d237eff --- /dev/null +++ b/.changeset/brown-impalas-judge.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: correct invalid() documentation to use issue parameter instead of invalid.fieldName() syntax From e0abb4fd64f843a6ba8be55cbdd4029f5ba4e8eb Mon Sep 17 00:00:00 2001 From: Tee Ming Date: Fri, 2 Jan 2026 14:31:40 +0800 Subject: [PATCH 4/6] Delete .changeset/brown-impalas-judge.md --- .changeset/brown-impalas-judge.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .changeset/brown-impalas-judge.md diff --git a/.changeset/brown-impalas-judge.md b/.changeset/brown-impalas-judge.md deleted file mode 100644 index 7d8f0d237eff..000000000000 --- a/.changeset/brown-impalas-judge.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@sveltejs/kit': patch ---- - -fix: correct invalid() documentation to use issue parameter instead of invalid.fieldName() syntax From e7899caf7c550c5d8e5991bb8f47d404a3fb995e Mon Sep 17 00:00:00 2001 From: Tee Ming Date: Fri, 2 Jan 2026 15:09:52 +0800 Subject: [PATCH 5/6] Clarify usage of invalid function in validation Updated the explanation of the `invalid` function to include its origin from `@sveltejs/kit` and clarified its usage. --- .../docs/20-core-concepts/60-remote-functions.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/documentation/docs/20-core-concepts/60-remote-functions.md b/documentation/docs/20-core-concepts/60-remote-functions.md index d12c454001b7..acab652c57f5 100644 --- a/documentation/docs/20-core-concepts/60-remote-functions.md +++ b/documentation/docs/20-core-concepts/60-remote-functions.md @@ -454,7 +454,10 @@ Alternatively, you could use `select` and `select multiple`: ### Programmatic validation -In addition to declarative schema validation, you can programmatically mark fields as invalid inside the form handler using the `invalid` function. This is useful for cases where you can't know if something is valid until you try to perform some action. Just like `redirect` or `error`, `invalid` throws. It expects a list of strings (for issues relating to the form as a whole) or standard-schema-compliant issues (for those relating to a specific field). Use the `issue` parameter for type-safe creation of such issues: +In addition to declarative schema validation, you can programmatically mark fields as invalid inside the form handler using the `invalid` helper from `@sveltejs/kit`. This is useful for cases where you can't know if something is valid until you try to perform some action. + +- It throws just like `redirect` or `error` +- It accepts multiple arguments that can be strings (for issues relating to the form as a whole and will show up in `fields.allIssues()`) or standard-schema-compliant issues (for those relating to a specific field). Use the `issue` parameter for type-safe creation of such issues: ```js /// file: src/routes/shop/data.remote.js @@ -484,12 +487,6 @@ export const buyHotcakes = form( ); ``` -The `invalid` function throws a validation error with the provided issues: - -- Call `invalid(issue1, issue2, ...issueN)` to throw a validation error -- If an issue is a `string`, it applies to the form as a whole (and will show up in `fields.allIssues()`) -- Use the `issue` parameter (provided by the form callback) to create issues for specific fields. It is type-safe and you can use regular property access syntax to create issues for deeply nested objects (e.g. `issue.profile.email('Email already exists')` or `issue.items[0].qty('Insufficient stock')`) - ### Validation If the submitted data doesn't pass the schema, the callback will not run. Instead, each invalid field's `issues()` method will return an array of `{ message: string }` objects, and the `aria-invalid` attribute (returned from `as(...)`) will be set to `true`: From c8f6a125e15db9c51daea979165b149ff5be8ace Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 14 Jan 2026 09:26:25 -0500 Subject: [PATCH 6/6] Update documentation/docs/20-core-concepts/60-remote-functions.md --- documentation/docs/20-core-concepts/60-remote-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/docs/20-core-concepts/60-remote-functions.md b/documentation/docs/20-core-concepts/60-remote-functions.md index acab652c57f5..b821bd1dfabf 100644 --- a/documentation/docs/20-core-concepts/60-remote-functions.md +++ b/documentation/docs/20-core-concepts/60-remote-functions.md @@ -457,7 +457,7 @@ Alternatively, you could use `select` and `select multiple`: In addition to declarative schema validation, you can programmatically mark fields as invalid inside the form handler using the `invalid` helper from `@sveltejs/kit`. This is useful for cases where you can't know if something is valid until you try to perform some action. - It throws just like `redirect` or `error` -- It accepts multiple arguments that can be strings (for issues relating to the form as a whole and will show up in `fields.allIssues()`) or standard-schema-compliant issues (for those relating to a specific field). Use the `issue` parameter for type-safe creation of such issues: +- It accepts multiple arguments that can be strings (for issues relating to the form as a whole — these will only show up in `fields.allIssues()`) or standard-schema-compliant issues (for those relating to a specific field). Use the `issue` parameter for type-safe creation of such issues: ```js /// file: src/routes/shop/data.remote.js