Make fallback
optionally get nested fallbacks recursively
#1173
Labels
question
Further information is requested
In zod defining a
.default({})
on az.object
whose properties has default values itself will recursively get the nested default values and merge them into the top level default value:Valibot however just simply takes the top level fallback value, and ignores the rest of the fallback values:
I already know about
getFallbacks
which I could use to get the same behaviour, but requires an extra step of defining the top level object first without fallback and then adding it with thegetFallbacks
function call for the fallback value:Now this isn't a huge hassle, but still a slight inconvenience compared to zod's
default
implementation 👀Would it maybe be possible to somehow make the
fallback
function recursively get the nested fallback values as well, like zod'sdefault
does? I am aware that this might not be desirable for some cases, so it should be behind an option of sort, or maybe be a different function entirely? Maybe I'm also missing something that already does this in a simpler way, or maybe this isn't possible due to the modular nature of the project. Anyhow, I thought I'd share this to open a discussion. Thanks for reading!The text was updated successfully, but these errors were encountered: