Can you generate a schema from the Reflection API? #733
-
I was reading about the reflection API and I was wondering if you serialize the schema as JSON, is it possible to generate a new Valibot schema from the metadata? {
"kind": "schema",
"type": "object",
"expects": "Object",
"async": false,
"entries": {
"bar": {
"kind": "schema",
"type": "string",
"expects": "string",
"async": false
}
}
} Would it be possible to dynamically generate the equivalent of this: const MySchema1 = v.object({
bar: v.string(),
}); |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Yes, this technically works for most schemas, methods, and actions, but I do not have time to implement it at the moment. Feel free to start a community project for this use case. |
Beta Was this translation helpful? Give feedback.
-
Hi all, I vibe-coded something like this over the weekend. Let's see where it goes :) |
Beta Was this translation helpful? Give feedback.
Yes, this technically works for most schemas, methods, and actions, but I do not have time to implement it at the moment. Feel free to start a community project for this use case.