Closed seba9989 closed 6 months ago
There is no standard way to serialize a file into json. Are you using some kind of web framework that uses json to transfer files ? I don’t think this lib should try to convert any non standard json types but I could look into adding an option to let you customize how unsupported valibot schema should be converted to json schema
Specifically, I use a library for sveltekit which this allows for convenient handling of forms. (https://superforms.rocks/get-started/valibot). Adapter module for valibot will exploit your project.
v0.0.26 now provides a customSchemaConversions option
You can now do toJSONSchema({ schema: instance(File), customSchemaConversions: { instance: () => ... } })
and decide how you want to convert unsupported instance schema into JSON schema.
To skip the validation you could just return an empty JSON schema ({}
)
Looks like AJV (a JSON schema validator) offers extensions to handle JS instanceof: https://ajv.js.org/packages/ajv-keywords.html#instanceof
customSchemaConversions
could definitely be used to output an ajv compatible schema for the valibot instance schema
Hello,
I would like to know how to use instance (for example: instance(File)) with valibot-json-schema.
And if there is no support for this type I would like to know if it is planned.
Thanks!