shapeshift's default with respect to surroundings
Solution:Jump to solution
Once we implement
when
, You'll be able to do it like this
```ts
s.object({
name: s.enum("A", "B"),
other: s.object({ name: s.string }).when('name', {...15 Replies
With actual code block
oh wait yea sorry
also can I make a recursive shape
@Vladdy might be able to answer quicker than me or @P<z, x>
I don't think this is possible now it will be possible after adding
when
I don't fully understand the question
basically if the name is "A", then the default is { name: "abc" }, if its "B", then the default is { name: "bca" }
Oh, conditional defaults
Solution
Once we implement
when
, You'll be able to do it like this
and the recursive object thing, what I mean is
Iirc we do support recursivity
yeah
how do I do it tho, cuz js doesn't allow using the variable before declaration
It should work
I don't remember exactly how to do it
true. In general, if anything isn't possible in js won't be possible in shapeshift too. But u can do it using
lazy
https://github.com/sapphiredev/shapeshift/blob/807666ef537c84d2e0f8bd9f4ce1a8060bfb3fb5/tests/validators/lazy.test.ts#L40oki, thanks