arktype

A

arktype

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

Join

subtypes available on scope in 2.0.0-beta.6

I have a scope defined but not seeing subtypes available
No description

How to handle checkbox in type('parse.formData').to(...)

I want turn the checkbox into boolean, but the checkbox field only produce "on" when checked, and missing when unchecked...

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 ```ts export const loginPayload = type( {...

Error internationalization (i18n)

Hello! Is it possible to translate the errors into other languages? In my previous setup I was using this for such funtionality: https://github.com/aiji42/zod-i18n ...

Tried to initialize an $ark registry in a monorepo

Hello! In a pnpm workspace, I have 2 packages depending on arktype. This means that each package depends on arktype separately. However, when I import them into a central vite project, I get the error: ``` Tried to initialize an $ark registry but one already existed. This probably means you are either depending on multiple versions of an arktype package, or importing the same package from both ESM and CJS. Review package.json versions across your repo to ensure consistency....

Adding comment to object key

Hello! What would be the right way to add comments to an object's key, like you do with /** */? I tried this, but it didn't work: ```ts output: type({...

Optional key

Hello! How can I define an array, which is also not required as an optional key? Is this the easiest way? https://discord.com/channels/957797212103016458/957804102685982740/1213198676349026355 ```ts // Goal: {...

Convert string to number with constraints

Hi, I'm looking at switching from Zod to Arktype mainly based on the serializable nature of types (lots of database driven forms). I'm stuck on something I think should be simple... - I'm passing FormData to the server. - Some of the fields are numeric, but are passed as strings (as FormData does)...

ArkType mutates original input?

I was always under the assumption that ArkType leaves the original input intact. However: ```ts import { type } from "arktype"; const original = { value: "100" };...

ParseError: Root of kind union should be one of alias,intersection,unit,domain,proto

```ts import { type } from "arktype"; const Amount = type("string|number") .pipe((s, ctx) => {...

Type Magic: validation on type property

How to validate defs in object type properties? ```ts export type validateSchema< def, schema,...

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...

Can you create types with dynamic literals?

Say I have this function: ```ts const createType = <T extends string>(code: T) => { const literal: string = code; return type({...

Cannot assign to Type

```ts import { scope, Type } from "arktype"; const ValidationErrorResponse = scope({ ErrorDescription: {...

How to validate `Record<string, string>`?

My naïve attempt: ```ts const Response = type({ "*": "string", });...

Property 'name' is missing in type

```ts const MyErrorResponse = scope({ Error: { message: "string", code: "string",...

Type 'distillOut<T>' is not assignable to type 'T'.

```ts import { type, Type } from "arktype"; const test = <T>(validator: Type<T>): T => { const result = validator({});...

How to improve error messages?

address must be a string and less than length 200 and more than length 50 and valid according to an anonymous predicate and valid according to an anonymous predicate and valid according to an anonymous predicate (was missing)
This is an example of a validation error message returned. How could I go about making that a little more human friendly?...

Pipe required before narrow

const myFunc = (v: string) => true;
const MyString = type("50<string<200").narrow((s) => myFunc(s));
const myFunc = (v: string) => true;
const MyString = type("50<string<200").narrow((s) => myFunc(s));
Results in error:...