Marvin
Aarktype
•Created by Marvin on 12/9/2024 in #questions
Framework-level onDeepUndeclaredKey
Hi, thanks for this awesome library!
I'm implementing arktype for my team and I plan on using it for DTOs which would validate the input and the output of our tRPC functions.
For the output DTOs, I want to enforce the deletion of "deep undeclared keys" to make sure we don't leak any information, like this:
While it works great, I'd like to enforce this at the framework-level, to make sure we never forget to add this
onDeepUndeclaredKey('delete')
.
I thought about doing a dto
function wrapper, like this:
But I have a Property 'onDeepUndeclaredKey' does not exist on type 'instantiateType<inferDefinition<def, {}, bindThis<def>>, {}>'.
error. However, doing dto().onDeepUndeclaredKey('delete')
works, for some reason.
I could // @ts-expect-error
but I'd rather have a clean implementation 😉
Do you have any idea or alternative to achieve what I'm trying to? I think this is a fairly common use-case and a clean solution and docs would be great.
Thanks!6 replies