Open adrian-gierakowski opened 4 days ago
export declare const schemaBodyUrlParams: <
A,
I extends Readonly<Record<string, string>>,
R,
>(
schema: Schema.Schema<A, I, R>,
options?: ParseOptions | undefined,
) => Effect.Effect<A, any, HttpServerRequest | R>
^taken from @effect/platform
, this shows exactly this thing. Though it should be Record<string, string | string[]>
I think
Though it should be Record<string, string | string[]> I think
Yeah that's the thing. On the wire, query parameters are always (string, string)
pairs, but it is actually possible to serialise strings, array of strings or even objects so the situation is not trivial. Tho, the way to approach this is to probably start with string | string[]
as a type constraint of the value and wait for user feedback.
but it is actually possible to serialise strings, array of strings or even objects so the situation is not trivial
How would you deserialise this without user providing a schema from string | string[]
to whatever they want to get on the other side? It’s the job of the user provided schema (unless you want to do some guess work) so I don’t see how any other would make sense as input.
but it is actually possible to serialise strings, array of strings or even objects so the situation is not trivial
How would you deserialise this without user providing a schema from
string | string[]
to whatever they want to get on the other side? It’s the job of the user provided schema (unless you want to do some guess work) so I don’t see how any other would make sense as input.
yeah, the user needs to use something like Schema.Union(Schema.String, Schema.Array(Schema.String))
(see also https://github.com/sukovanej/effect-http/issues/441)
for example, this compiles:
but fails at runtime:
As far as I can tell, there is no valid way to call this route.
Same applies to the following:
which fails as follows:
To fix it I can use
Schema.NumberFromString
but ideally we'd want the compiler to enforce schemas to be valid.