-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
Describe the bug
In my repo i have input field that is optional and when it's filled it has to be an json object with a specific structure ( in my case an array with coordinates ).
I've the following validation in my schema:
{
...
bounds: v.optional(v.pipe(v.string(), transformJson, boundsSchema))
...
}
transformJson = v.transform((input: string) => {
try {
return JSON.parse(input);
} catch {
return {};
}
});
const boundsSchema = v.array(v.tuple([v.number(), v.number()]));My Problem is that an empty Input Text field is included as an empty string in the request to the remote function.
I don't know if this is the default behavior from now on and i have to bypass this with some conditional validation or if this is just a bug with the transformation from the form data to an object.
Thanks for your help
Reproduction
The empty string can be seen when just submitting without inputting anything
Request Data:
Logs
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 20.19.1 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.8.2 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
@sveltejs/adapter-auto: ^6.0.0 => 6.1.0
@sveltejs/kit: 2.46.4 => 2.46.4
@sveltejs/vite-plugin-svelte: ^6.0.0 => 6.2.0
svelte: ^5.39.11 => 5.39.11
vite: ^7.0.4 => 7.1.5Severity
annoyance
Additional Information
No response
Metadata
Metadata
Assignees
Labels
No labels
