You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a use case where I'd like to have a query string parameter (type) to be either a string or an array of strings if defined, otherwise allow it to be optional.
I'm pretty new to AdonisJS so if might just be me learning, but I couldn't figure out how to do it without a more complicated approach.
I have a use case where I'd like to have a query string parameter (
type
) to be either a string or an array of strings if defined, otherwise allow it to be optional.I'm pretty new to AdonisJS so if might just be me learning, but I couldn't figure out how to do it without a more complicated approach.
I tried this approach which seems reasonable:
and I got an error that I couldn't use
.optional()
on a union.So, I ended up with something like this (which I'm not sure is the best approach though it worked):
But then in the controller when I do:
I get the typescript error:
Property 'type' does not exist on type '{} & {}'
.I would love if
.union()
would allow.optional()
unless there is a better way that I'm not aware of.Thanks.
The text was updated successfully, but these errors were encountered: