Hello, thank you for Valibot!
Is there a way to extract a partial schema from a variant type like this one:
import * as v from 'valibot';
const VariantScheme = v.variant('type', [
v.object({
type: v.literal('foo'),
data: v.string(),
}),
v.object({
type: v.literal('bar'),
data: v.number(),
}),
v.object({
type: v.literal('baz'),
data: v.null_(),
}),
]);
To get a schema of specific fields without repeating yourself:
const TypeScheme = v.union([v.literal('foo'), v.literal('bar'), v.literal('baz')]);
const DataScheme = v.union([v.string(), v.number(), v.null_()]);
Unfortunately, pick and omit do not accept VariantSchema as an input.
If it is already possible, please add an example to the docs: https://valibot.dev/guides/unions/
Hello, thank you for Valibot!
Is there a way to extract a partial schema from a variant type like this one:
To get a schema of specific fields without repeating yourself:
Unfortunately,
pickandomitdo not accept VariantSchema as an input.If it is already possible, please add an example to the docs: https://valibot.dev/guides/unions/