Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/funny-seas-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: preserve `this` when invoking standard validator
5 changes: 2 additions & 3 deletions packages/kit/src/runtime/app/server/remote/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ export function create_validator(validate_or_fn, maybe_fn) {
return async (arg) => {
// Get event before async validation to ensure it's available in server environments without AsyncLocalStorage, too
const { event, state } = get_request_store();
const validate = validate_or_fn['~standard'].validate;

const result = await validate(arg);
// access property and call method in one go to preserve potential this context
const result = await validate_or_fn['~standard'].validate(arg);

// if the `issues` field exists, the validation failed
if (result.issues) {
Expand Down
Loading