How to use a Set in default values?
I am using Select from Hero UI, which uses a Set for its value. But when I do this, the schema validator types do not come out correctly. It seems they are transforming the types to be serializable, converting from Set to Array.
Here's a mini code snippet to reproduce:
Is there something I am missing?
11 Replies
wise-whiteOP•4w ago
Here's the error
wise-whiteOP•4w ago
wise-whiteOP•4w ago
One way I solved this is to control the type so only arrays are set on the form instead of sets
flat-fuchsia•4w ago
does the schema allow you to view its input type?
the standard schema spec requires them to be around, but I don‘t know the syntax to get them for this library
wise-whiteOP•4w ago
Yeah, that's done through what I have above
flat-fuchsia•4w ago
So if you write
what errors does it say it has with your previous stuff? Is it compatible?
wise-whiteOP•4w ago
That's the same as the type cast I have above:
flat-fuchsia•4w ago
a type cast is just that: a cast. It expects you to know for sure that it's compatible, which isn't type safe.
The code I sent instead checks whether it actually is the same or not
wise-whiteOP•4w ago
Ah, right. Here's a minimal reproduction:
wise-whiteOP•4w ago
flat-fuchsia•4w ago
yeah, so it looks like the schema spec expects to receive an array and not a set. Weird how the spec would change that?