arktype

A

arktype

This is a friendly space centered around ArkType, TypeScript's 1:1 validator (https://github.com/arktypeio/arktype)

Join

Stanard Schema issues conformance

Hello! As I've been playing with Tanstack Start, it seems that there's an issue with how Arktype handles issues. Standard Schema defines, that issues should look like this: ```ts /** The result interface if validation fails. */...
No description

Schemas with cyclic references

In Zod, I can create circular schemas like this: ```ts const typeABaseSchema = z.strictObject({ type: z.literal("a"),...

Throw on failed validation

Does Arktype throws on failed validation? I saw that there's a onFail in docs, so I've configured it and imported it before artype itself in place of use, but still no error was thrown. ```ts // arktype-conf.ts import { configure } from "arktype";...

type for valid JSON value?

Is there a built-in or easy way to make sure a given input is a valid JSON value? Basically the opposite of type("string.json.parse") I guess

Is it possible to define a type that does this?

I'm trying to define a morph that turns the presence of a string key into true and the absence of the key results in false. In the below, I can't work out how to define myType to get the result I want, or if it's even possible? ```typescript...

How to make an `Int32Array<SharedArrayBuffer>`?

Doing TypedArray.Int32 gives Int32Array<ArrayBufferLike> but I want Int32Array<SharedArrayBuffer> This probably applies to customizing any type of the int32 array but this is all I personally care about....

How to create an arktype generic from a generic class<>?

My expectation: ``` const page = type.instanceOf(Page); const pageWithType = page(type("string"))...

Merge union?

How would I merge a union to have more options seeing as union doesnt have merge method? Base Union const payment_methods = type("'credit_card' | 'debit_card' | 'eft' | 'apple_pay' | 'samsung_pay' | 'visa_checkout'") ...

array of objects?

How do you declare an array of objects?

Inference issues while trying to be generic over a type

I am trying to create a form state helper function that takes a schema and an initial value. I am not getting any ts errors but the type of form infers to "anyOrNever" & Record<string, unknown> this is the relevant function ```ts...

ArkType type matcher vs Effect Match module

Hello, wanted to discuss the newly released type matcher and how would it differ from the Effect Match module. I know Effect Match module has a couple of limitations in the way it works and I'm also not sure arktype type matcher and Effect Match are up for comparison, based on their goals. So just wanted to reach out and see if anyone's wondering the same and if some of you have some answers and comparisons already. Thanks!

Is there a better way to write this?

import { type } from "arktype"; export const nonEmptyStringOrNull = type("string | null | undefined").pipe(s => !s ? null : s);...

Section hero video

Hey, quick question: I would like to know how you made this video (on the home page of https://arktype.io/), what tools did you use ?

Is there a good way to use an array of fields mapped from an object into array as string literals?

So probably really simple and I am just missing something. I am trying to achieve the following: ```ts...

ArkType `toJsonSchema` returning not open-api compatible schema.

Hi, I am trying to get my arktype schemas working with fastify (was previously using zod but editor performance was tragic) so I started with setting OpenAPI. Zod tools use https://www.npmjs.com/package/zod-to-json-schema for this but since ArkType has a method built in I decided to use it the output however is different and zod's one actually uses enums/unions in a way that openapi can handle. ```ts...

Configure errors in a scope

Is it possible to set a expected/actual/etc handler for every type in a scope? I have something like this: ```ts const foo = type({...

How to choose "one of" in a type?

Hi there! ```ts export const user_find_one_controller_input = type({ "_id?": userApi.schema.user.get("_id"),...

Get ts type that accepts type arguments

I have a type that looks like this: ```ts interface PluginInstance<Input, TInput, Diff> { details: PluginDetails...

"Custom" type or equivalent to valibot.custom()?

I might just be missing something obvious, but I want to do something like this: ```ts import type { SomeType } from "some-external-library" ...