toValuesSchema
The toValuesSchema method converts a mapping of Valibot schemas into a TinyBase ValuesSchema.
toValuesSchema(schemas: {[valueId: string]: any}): ValuesSchema| Type | Description | |
|---|---|---|
schemas | {[valueId: string]: any} | A mapping of value IDs to Valibot schemas. |
| returns | ValuesSchema | A TinyBase |
This method extracts basic type information and fallback values from Valibot schemas.
Example
This example converts Valibot value schemas.
import {createStore} from 'tinybase';
import {createValibotSchematizer} from 'tinybase/schematizers/schematizer-valibot';
import {fallback, number, string} from 'valibot';
const schematizer = createValibotSchematizer();
const valuesSchema = schematizer.toValuesSchema({
theme: fallback(string(), 'light'),
count: number(),
});
const store = createStore().setValuesSchema(valuesSchema);
console.log(store.getValues());
// -> {theme: 'light'}
Since
v7.1.0