You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently migrating from zod to valibot but haven't been able to get instance to work.
Here is the original Zod code:
pictures: z.instanceof(File,{message: 'Please upload a file.'}).array().refine((files)=>files.length!==0,'At least one image is required').refine((files)=>files.length<=MAX_NUM_PICTURES,`Maximum number of pictures is ${MAX_NUM_PICTURES}`).refine((files)=>files.every((f)=>sizeInMB(f.size)<=MAX_IMAGE_SIZE),'Max 4MB upload size.').refine((files)=>files.every((f)=>ACCEPTED_IMAGE_TYPES.includes(f.type)),'Unsupported file type.')
And here is my attempted translation to Valibot:
pictures: array(instance(File,'',[mimeType(ACCEPTED_IMAGE_TYPES,'Unsupported file type.'),custom((file)=>sizeInMB(file.size)<=MAX_IMAGE_SIZE,'Max 4MB upload size.')]),[custom((files)=>files.length!==0,'At least one image is required'),custom((files)=>files.length<=MAX_NUM_PICTURES,`Maximum number of pictures is ${MAX_NUM_PICTURES}`)])
I get the following error
Error: Unsupported valibot schema: instance
at assert (file:///C:/Users/mario/Escritorio/Unihouse/node_modules/@gcornut/valibot-json-schema/dist/index.mjs:21:11)
at converter (file:///C:/Users/mario/Escritorio/Unihouse/node_modules/@gcornut/valibot-json-schema/dist/index.mjs:226:5)
at object (file:///C:/Users/mario/Escritorio/Unihouse/node_modules/@gcornut/valibot-json-schema/dist/index.mjs:124:29)
at converter (file:///C:/Users/mario/Escritorio/Unihouse/node_modules/@gcornut/valibot-json-schema/dist/index.mjs:227:23)
at Module.toJSONSchema (file:///C:/Users/mario/Escritorio/Unihouse/node_modules/@gcornut/valibot-json-schema/dist/index.mjs:248:35)
at valibotToJSONSchema (C:\Users\mario\Escritorio\Unihouse\node_modules\sveltekit-superforms\dist\adapters\valibot.js:13:12)
at _valibot (C:\Users\mario\Escritorio\Unihouse\node_modules\sveltekit-superforms\dist\adapters\valibot.js:36:44)
at Module.memoized (C:\Users\mario\Escritorio\Unihouse\node_modules\memoize-weak\lib\memoize.js:79:20)
at load (C:\Users\mario\Escritorio\Unihouse\src\routes\(app)\publish\new\+page.server.js:12:29)
at Module.load_server_data (C:\Users\mario\Escritorio\Unihouse\node_modules\@sveltejs\kit\src\runtime\server\page\load_data.js:61:41)
I've also tried a simpler test directly from the Valibot documentation:
Thank you creating this issue. It seems that this error is not related to Valibot. It is related to valibot-json-schema. Please create an issue there. Feel free to link me.
I'm currently migrating from zod to valibot but haven't been able to get
instance
to work.Here is the original Zod code:
And here is my attempted translation to Valibot:
I get the following error
I've also tried a simpler test directly from the Valibot documentation:
However, all attempts result in the same error. I even tried using just
instance(File)
.I'd appreciate any insights or assistance in resolving this issue. Thank you!
The text was updated successfully, but these errors were encountered: