TinyBase logoTinyBase β

createZodSchematizer

The createZodSchematizer function creates a ZodSchematizer object that can convert Zod schemas into TinyBase schemas.

createZodSchematizer(): ZodSchematizer
returnsZodSchematizer

A new ZodSchematizer instance.

The schematizer is stateless and can be reused for multiple conversions.

Example

This example creates a Zod schematizer and uses it to convert schemas.

import {createZodSchematizer} from 'tinybase/schematizers/schematizer-zod';
import {z} from 'zod';

const schematizer = createZodSchematizer();

const tablesSchema = schematizer.toTablesSchema({
  pets: z.object({
    species: z.string(),
  }),
});
console.log(tablesSchema);
// -> {pets: {species: {type: 'string'}}}

Since

v7.1.0