Usage for HTTP validation
I'm looking to use Arktype as a Request/Response validator
This comes with the following requirements:
- Request body should be validated with deep
reject
unknownKeys so invalid requests are immediately 422
- Response should be validated with deep delete
unknownKeys so local information can't passthrough
- Response input should be cloned rather then inline-morphed (including key deletion) so you can pass in input objects as-is
Please list recommended AT APIs for this
Please link the related undone issues is any36 Replies
Unknown Userā¢4mo ago
Message Not Public
Sign In & Join Server To View
Well, it's either 400 or 422, and if you want to 400 for whatever else it's 422
Github uses
422 Validation failed
As I understood it's history, 422 did mean "you sent valid XML but its contents is š©"
So 400 is more or JSON.parse failure then validation failure
@ssalbdivad pingI've already answered this haven't I?
ah, it's still sumday, nevermind
I am working today
Oh
Maybe you meant the m
I've made this #questions so I don't ever ask it again
Actually I added a deep param for onUndeclaredKey
I still can't configure it at a scope level yet that's tricky and kinda what I'm working on now
Have to be very careful with caching across scopes
So, I'd like to have a unit test for this
So please list what functions I need and I'll try to make one
If you want to fuck around with stuff though which you generally do maybe you should look at the
transform
API on t.raw
(t.internal
on the next release).Hmm
What that does?
Deeply transforms type nodes
Ah
Here's how I use it to configure description at multkple levels:
Here's the new
onUndeclaredKey
implementation:
You'd have to learn a bit about the different node kinds to use this effectively but it is very powerful for this sort of thing
What are the cases you are referring to?Validation of untrusted input and serialization of untrimmed output?
Using exact same input Type
A la Zod's default behaviour I guess (is it? I didn't really use zod)
Or what are you asking
So, I'd like to have a unit test for this So please list what functions I need and I'll try to make oneWhat are you asking for the names of the APIs?