sveltejs/kit · error
Invalid validator passed to remote function. Expected "unche
Error message
Invalid validator passed to remote function. Expected "unchecked" or a Standard Schema (https://standardschema.dev)
What it means
`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.
Source
Thrown at packages/kit/src/runtime/app/server/remote/shared.js:42
return (arg) => arg;
}
// use https://standardschema.dev validator if provided
if ('~standard' in validate_or_fn) {
return async (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) {
throw new ValidationError(result.issues);
}
return result.value;
};
}
throw new Error(
'Invalid validator passed to remote function. Expected "unchecked" or a Standard Schema (https://standardschema.dev)'
);
}
/**
* In case of a single remote function call, just returns the result.
*
* In case of a full page reload, returns the response for a remote function call,
* either from the cache or by invoking the function.
* Also saves an uneval'ed version of the result for later HTML inlining for hydration.
*
* @template {MaybePromise<any>} T
* @param {RemoteInternals} internals
* @param {string} payload — the stringified raw argument (i.e. the cache key the client will use)
* @param {RequestState} state
* @param {() => Promise<T>} get_result
* @returns {Promise<T>}
*/View on GitHub (pinned to 03f1687fe6)
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()`).
Example fix
// before
export const getUser = query((id) => db.getUser(id), (arg) => typeof arg === 'string');
// after
import { z } from 'zod';
export const getUser = query((id) => db.getUser(id), z.string()); Defensive patterns
Strategy: validation
Validate before calling
function isStandardSchema(v) {
return v === 'unchecked' || (v && typeof v === 'object' && '~standard' in v);
}
// assert before declaring: if (!isStandardSchema(mySchema)) throw new TypeError('...'); Type guard
function isStandardSchema(v) {
return !!v && (typeof v === 'object' || typeof v === 'function') && '~standard' in v;
} Try / catch
// This throws at module init, so wrap the declaration site if dynamic:
try {
const fn = query(handler, maybeSchema);
} catch (e) {
if (e.message.includes('Invalid validator')) useUncheckedFallback();
else throw e;
} Prevention
- 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.
When it happens
Trigger: 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`.
Common situations: 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.
Related errors
- new ValidationError(result.issues) — carries the Standard Sc
- Invalid value for environment variable ${name}: ${JSON.strin
- Unsupported runtime: ${key}. Supported runtimes are: ${valid
- Skipping ${__.name}(${payload})
- Cookies set in remote functions must have an absolute path
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/6206be800e61f39c.
Report an issue: GitHub.