Create ArkType type from standard schema from other library.
Is it possible for me to integrate Standard Schemas from other libraries such as Effect.Schema or Zod with ArkType?
I am using Effect and trying to use their Config module which seems built on their Schema type which can be exported to Standard Schema. I really don't want to redefine my schemas/types and am wondering if ArkType supports using other Standard Schema types to create its types?
7 Replies
I actually love this idea that any standard schema would just be a valid arktype definition
I don't know why I haven't already done it
I will add that in the next release
(of course you can do it manually now with a thin wrapper like
typeFromStandardSchema but there's really no reason to not have that concept built-in)
so you could use any standard-schema compliant object anywhere it would be valid to pass a TypeThat would be so awesome.
How would one go about implementing
typeFromStandardSchema in the interim? Is it actually really simple?yeah it is one sec
@Damian Reeves try this:
there was a little more than I was originally imagining because of the error mapping but still pretty easy and seems to work
also created this to track adding it to the next release which will mostly just be this implementation:
https://github.com/arktypeio/arktype/issues/1550
Thanks so much! I'll take a look and give it a shot
thanks for the great idea!
@Damian Reeves as of 2.1.28 you can pass Standard Schema directly to ArkType:
"Migrate your codebase to ArkType" and it's all type(z.object({ ... }))