{"record":{"id":"6206be800e61f39c","repo":"sveltejs/kit","slug":"invalid-validator-passed-to-remote-function-expec","errorCode":null,"errorMessage":"Invalid validator passed to remote function. Expected \"unchecked\" or a Standard Schema (https://standardschema.dev)","messagePattern":"Invalid validator passed to remote function\\. Expected \"unchecked\" or a Standard Schema \\(https://standardschema\\.dev\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/kit/src/runtime/app/server/remote/shared.js","lineNumber":42,"sourceCode":"\t\treturn (arg) => arg;\n\t}\n\n\t// use https://standardschema.dev validator if provided\n\tif ('~standard' in validate_or_fn) {\n\t\treturn async (arg) => {\n\t\t\t// access property and call method in one go to preserve potential this context\n\t\t\tconst result = await validate_or_fn['~standard'].validate(arg);\n\n\t\t\t// if the `issues` field exists, the validation failed\n\t\t\tif (result.issues) {\n\t\t\t\tthrow new ValidationError(result.issues);\n\t\t\t}\n\n\t\t\treturn result.value;\n\t\t};\n\t}\n\n\tthrow new Error(\n\t\t'Invalid validator passed to remote function. Expected \"unchecked\" or a Standard Schema (https://standardschema.dev)'\n\t);\n}\n\n/**\n * In case of a single remote function call, just returns the result.\n *\n * In case of a full page reload, returns the response for a remote function call,\n * either from the cache or by invoking the function.\n * Also saves an uneval'ed version of the result for later HTML inlining for hydration.\n *\n * @template {MaybePromise<any>} T\n * @param {RemoteInternals} internals\n * @param {string} payload — the stringified raw argument (i.e. the cache key the client will use)\n * @param {RequestState} state\n * @param {() => Promise<T>} get_result\n * @returns {Promise<T>}\n */","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/app/server/remote/shared.js#L24-L60","documentation":"`create_validator` accepts only the string `'unchecked'` or an object implementing Standard Schema (`'~standard' in validator`). Anything else passed as the second argument to a remote function declaration cannot be used as a validator, so SvelteKit throws at module initialization time.","triggerScenarios":"Declaring `query(fn, myValidator)` where `myValidator` is a plain function, a non-Standard-Schema class instance, `undefined` with a function arg mismatch, or a validator from a library without Standard Schema support; also passing a schema built by an outdated library version lacking `~standard`.","commonSituations":"Using an old zod/yup version predating Standard Schema; hand-rolling a validator object; passing a resolver function instead of a schema; typos like passing `schema.shape.x` instead of the schema.","solutions":["Pass a Standard Schema-compliant schema (zod ≥3.24, valibot, arktype) instead of a custom object/function.","Upgrade the validation library to a version exposing the `~standard` property.","Use the literal `'unchecked'` if you intentionally want no validation.","If you only want input coercion plus validation, wrap your logic in a compliant schema (e.g. `z.custom()`)."],"exampleFix":"// before\nexport const getUser = query((id) => db.getUser(id), (arg) => typeof arg === 'string');\n// after\nimport { z } from 'zod';\nexport const getUser = query((id) => db.getUser(id), z.string());","handlingStrategy":"validation","validationCode":"function isStandardSchema(v) {\n  return v === 'unchecked' || (v && typeof v === 'object' && '~standard' in v);\n}\n// assert before declaring: if (!isStandardSchema(mySchema)) throw new TypeError('...');","typeGuard":"function isStandardSchema(v) {\n  return !!v && (typeof v === 'object' || typeof v === 'function') && '~standard' in v;\n}","tryCatchPattern":"// This throws at module init, so wrap the declaration site if dynamic:\ntry {\n  const fn = query(handler, maybeSchema);\n} catch (e) {\n  if (e.message.includes('Invalid validator')) useUncheckedFallback();\n  else throw e;\n}","preventionTips":["Use zod >= 3.24 / valibot / arktype, which implement Standard Schema.","Pass the schema object itself, never a wrapper function or resolver.","Use the literal 'unchecked' deliberately and sparingly.","Upgrade validation libraries when migrating to remote functions."],"tags":["validation","standard-schema","remote-functions","configuration"],"backgroundTag":"invalid-validator-argument","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}