0.0.8 • Published 9 months ago

@treasured/zod-to-leva-schema v0.0.8

Weekly downloads
-
License
-
Repository
-
Last release
9 months ago

zod-to-leva-schema

Converts a typed schema written in Zod into a schema that can be used by Leva.

We use this library in the Treasured player to easily modify portions of the level schema for debugging purposes.

Usage

Imagine we have the following schema written in Zod:

import { z } from "zod";

const FeaturesSchema = z.object({
  matterportStyleNavigation: z.boolean().default(true),
  guidedTour: z.boolean().default(false),
});

We can convert this into the equivalent schema in Leva:

import zodToLevaSchema from "@treasured/zod-to-leva-schema";
import { useControls } from "leva";

const levaSchema = zodToLevaSchema(FeaturesSchema);

and levaSchema will be:

{
    matterportStyleNavigation: {
        type: "boolean",
        value: false,
    },
    guidedTour: {
        type: "boolean",
        value: false,
    },
}
0.0.8

9 months ago

0.0.5

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago