Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@
"optionalDependencies": {
"@exodus/schemasafe": "^1.3.0",
"@finom/zod-to-json-schema": "^3.24.11",
"@gcornut/valibot-json-schema": "^0.42.0",
"@typeschema/class-validator": "^0.3.0",
"@vinejs/vine": "^3.0.1",
"arktype": "^2.1.22",
Expand All @@ -185,6 +184,7 @@
"zod": "^4.1.11"
},
"dependencies": {
"@valibot/to-json-schema": "^1.4.0",
"devalue": "^5.3.2",
"memoize-weak": "^1.0.2",
"ts-deepmerge": "^7.0.3"
Expand Down
85 changes: 13 additions & 72 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 5 additions & 18 deletions src/lib/adapters/valibot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,16 @@ import {
} from 'valibot';
import { memoize } from '$lib/memoize.js';
import {
type ToJSONSchemaOptions,
toJSONSchema as valibotToJSON
} from '@gcornut/valibot-json-schema';
toJsonSchema as valibotToJSON,
type ConversionConfig as ToJSONSchemaOptions
} from '@valibot/to-json-schema';
import type { JSONSchema } from '../jsonSchema/index.js';

type SupportedSchemas = GenericSchema | GenericSchemaAsync;

const defaultOptions = {
strictObjectTypes: true,
dateStrategy: 'integer' as const,
bigintStrategy: 'integer' as const,
ignoreUnknownValidation: true,
customSchemaConversion: {
custom: () => ({}),
instance: () => ({}),
file: () => ({}),
blob: () => ({})
}
} satisfies ToJSONSchemaOptions;

/* @__NO_SIDE_EFFECTS__ */
export const valibotToJSONSchema = (options: ToJSONSchemaOptions) => {
return valibotToJSON({ ...defaultOptions, ...options }) as JSONSchema;
export const valibotToJSONSchema = (options: ToJSONSchemaOptions & { schema: Parameters<typeof valibotToJSON>[0] }) => {
return valibotToJSON(options.schema, options) as JSONSchema;
};

async function _validate<T extends SupportedSchemas>(
Expand Down