dibbo
Aarktype
•Created by dibbo on 11/3/2024 in #questions
Generic middleware validator
Hello, I'm trying to write a middleware in my app that handles validating the incoming request body. It currently looks like this
The return type means that in my handler
body
comes through with the correct type definition given by the validator, e.g.
This has worked nicely so far, but unfortunately with larger schemas I'm getting a Type instantiation is excessively deep and possibly infinite
error when calling validateBody
.
I've read answers to similar questions here and here, and tried out some of the suggestions, but I haven't been able to come up with a solution so far.
Is there any way to get this working as expected, or is it not possible with the current limitations of Typescript? Am I safer just casting body
in the handler
to the expected type (since at that point it has passed validation and I know that it conforms to the expected type)?
Any help or suggestions would be greatly appreciated, thanks!6 replies
Aarktype
•Created by dibbo on 8/29/2024 in #questions
Optional property with const string array
Hello, the following
is giving a error. It's not really clear to me why - I assume the
===
operator is doing more than what I think.
Is there a way to have an optional property be one of a string array in arktype? Or is what I'm after effectively indexed access expressions? Thanks6 replies
Aarktype
•Created by dibbo on 8/27/2024 in #questions
Indexed Access Types
Hello, is it possible to recreate the
SizeValues
type below in arktype? 9 replies
Aarktype
•Created by dibbo on 8/16/2024 in #questions
Latest "keys:distilled" equivalent?
Hello, I started using ArkType a back in v1 and it has obviously come on leaps and bounds since then which is great to see.
However, back in v1 you could do something like
and once you validated a payload against this you would only ever get an object with
email
/password
keys.
I'm wondering how to achieve a similar result with the latest version of the library. Thanks.11 replies