arktype

A

arktype

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

Join

Configuring morphs in the scope/module level

I'm working on adding coercion to ArkEnv (issue with full context: https://github.com/yamcodes/arkenv/issues/228), since environment variables (in process.env) are always string | undefined, we want to be able to coerce them. Now: ```ts...

Parsing nested form data

Hi lovely folks! Does ArkType have built-in support for parsing nested form data, e.g. parsing a set of fields like address.street, address.postcode, etc into a schema address: { street: 'string', postcode: 'string', ... }?

Code generation from strings disallowed for this context

I am using cloudflare and its Vite plugin and am getting this error when using Arktype schemas. Build works fine, preview/deployed fails on request with this message. It seems to be isolated to Cloudflare Vite plugin builds. Idk if this thread helps any https://discord.com/channels/957797212103016458/1178476270879780944/1178476270879780944...

dynamic validation?

I have a schema like so: ```ts export const blog = type({ headline: "string > 0", description: "string > 0",...

Nested morphs not being applied

```typescript import { type Out, Type, type } from 'arktype' // import { Option } from 'ts-result-option' class Option<T> {...

Cast empty string in place for literal as default value

Hi, I'm trying to use an array of string literals for a select field using Superforms. However, I would like to have the default value be an empty string, so that the default select field is not selected. I've tried the following, but this doesn't seem to work ```ts...

Validating that a string isn't empty after trimming

Title says it all really. I want to have ArkType trim a string and then check its length, but type("string.trim > 0") doesn't work as the left side is a morph.

arktype with isolatedDeclarations

If you have a package that uses arktype and isolatedDeclarations: true in tsconfig.json (for speed, OXC/tsdown support), then you'll likely see this error: ```ts RollupError: TS9010: Variable must have an explicit type annotation with --isolatedDeclarations. x TS9010: Variable must have an explicit type annotation with...

JSDoc for keywords

Currently, we do not have JSDoc for built-in keywords (see image). This seems to suggest adding JSDoc is not possible in the current api for keywords. Is that right, or is that something that can be done? Asking because I'm curious to add JSDoc for my library (ArkEnv) that uses custom keywords....
No description

Extending built-in keywords

Hey folks 👋 I’m building a cool tool that uses (and extends) ArkType, and I'm trying to figure out the right way to "extend" the default keywords (like string, number, etc.) so they can have extra functionality/modules. Here’s what I’ve tried: ...

Is it possible to inferOut generics?

```typescript export const tableWidgetSchema = type("<t>", { records: "t[]", }); ...

Structure Node hinder DeepPartial

Hey, just stumbled across this amazing community and thought you might be able to help me. i was using a modified version of the deepPartial Function, that has been posted here https://discord.com/channels/957797212103016458/957804102685982740/1348929382261067777 I have stumbled into an issue with certain type definitions: ...

Simple question re a function that returns a type:

Trying to create simple "factory" functions that make a type based on some other type. This works fine: ```const makeBar = <T1, T2>(inputs: Type<T1>, outputs: Type<T2>) => type({ weird: "boolean", in: inputs,...

Can I make `string.yaml` like `string.json`?

I haven't been able to figure out a way of extending it with my own yaml https://arktype.io/docs/scopes#submodules 🤔

How to merge types with Generics

I'm trying hard to understand how to work with generics (arktype and typescipt too). ```typescript export const paginationRequest = < const def extends object,...

Can Arktype create discriminated unions based on whether a key exists?

``` typescript const MasterSkinItem = BaseItem.merge({ "+": "reject", type: "'skin'", masterItem: "true",...

examples of URLSearchParams

are there any examples of using arktype to turn URLSearchParams into a well formed, typed object? I see things like Headers are supported as types, but didn't see URLSearchParams...

How to validate all properties without bailing early?

I am using Arktype to validate forms. I would like to show all problems with a form. I am using unions to show some form elements conditionally. ``` export const OtherPropertyRow = type.merge( {...

How do I get the input type for `type`?

```ts export function validateEnv<T extends Record<string, unknown>>( def: ?, ) { const schema = type(def)...

.partial() is ruining the error scope

When i add .partial() to my type it seems to ruin the custom error messages of the fields inside my type. I created a reproduction here: https://arktype.io/playground?code=import%2520%257B%2520type%2520%257D%2520from%2520%2522arktype%2522%250A%250Aconst%2520productBase%2520%253D%2520type%28%257B%250A%2509dates%253A%2520type%28%257B%2520start%253A%2520%2522string%2522%252C%2520end%253A%2520%2522string%2522%2520%257D%29%250A%2509%2509.array%28%29%250A%2509%2509.atLeastLength%281%29%250A%2509%2509.configure%28%257B%2520message%253A%2520%2522Datess%2520are%2520required%2522%2520%257D%29%250A%257D%29%250A%250Aconst%2520ticket%2520%253D%2520type%28%257B%250A%2509%2522...%2522%253A%2520productBase%252C%250A%2509type%253A%2520%2522%27ticket%27%2522%250A%257D%29%250A%250Aconst%2520merchandise%2520%253D%2520type%28%257B%250A%2509%2522...%2522%253A%2520productBase%252C%250A%2509type%253A%2520%2522%27merchandise%27%2522%250A%257D%29%250A%250Aconst%2520Thing%2520%253D%2520type%28ticket%252C%2520%2522%257C%2522%252C%2520merchandise%29%250A%250A%252F%252F%2520Throws%2520correct%2520error%253A%2520%2522Datess%2520are%2520required%2522%250Aconst%2520out%2520%253D%2520Thing.from%28%257B%250A%2509type%253A%2520%2522ticket%2522%252C%250A%2509dates%253A%2520%255B%255D%250A%257D%29%250A%250A%252F%252F%2520Throws%2520incorrect%2520error%2520because%2520of%2520the%2520partial%28%29%253A%2520%2522dates_redeemable%2520must%2520be%2520exactly%2520length%25201%2520%28was%25200%29%2522%250Alet%2520otherOut%2520%253D%2520Thing.partial%28%29.from%28%257B%250A%2509type%253A%2520%2522ticket%2522%252C%250A%2509dates%253A%2520%255B%255D%250A%257D%29%250A...
Next