-
-
Notifications
You must be signed in to change notification settings - Fork 256
Open
Labels
fixA smaller enhancement or bug fixA smaller enhancement or bug fixnext versionSomething to look at for our next major releaseSomething to look at for our next major release
Milestone
Description
I'm not sure if this is a skill issue or a limitation of valibot but I have just run into some trouble with extracting fallback values and I'm not sure what else to try.
const VSearchParams = v.object({
units: v.fallback(v.union([v.literal("SI"), v.literal("IP")]), "IP"),
selectedCoordinate: v.fallback(
v.object({
longitude: coerceToNumber,
latitude: coerceToNumber,
}),
{
longitude: 30.2525,
latitude: -97.7539,
},
),
timeRange: v.fallback(
coerceToNumber,
1,
),
});
const t = v.getFallbacks(VSearchParams);
// const t: {
// units: "IP";
// selectedCoordinate: {
// longitude: undefined;
// latitude: undefined;
// };
// timeRange: 1;
// }
type t2 = v.InferOutput<typeof VSearchParams>;
// type t2 = {
// units: "SI" | "IP";
// selectedCoordinate: {
// longitude: number;
// latitude: number;
// };
// timeRange: number;
// }
const t3 = v.getFallback(v.fallback(
v.object({
longitude: coerceToNumber,
latitude: coerceToNumber,
}),
{
longitude: 30.2525,
latitude: -97.7539,
},
));
// const t3: {
// readonly longitude: 30.2525;
// readonly latitude: -97.7539;
// }
Metadata
Metadata
Assignees
Labels
fixA smaller enhancement or bug fixA smaller enhancement or bug fixnext versionSomething to look at for our next major releaseSomething to look at for our next major release