arktype

A

arktype

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

Join

[attest] Getting `requested module ... does not provide an export` error for my bench script

Hi šŸ‘‹ I'm having TS performance issues in my project. I think the offender is mainly tRPC with Zod and Drizzle, but I wanted to analyze a bit more before changing too much of my code. So I set up a very basic bench.ts script to check how long the tRPC appRouter would take to instantiate....

Uncaught (in promise) RangeError: Maximum call stack size exceeded

When using ArkType with svelte superforms, I'm getting the error: ``` justClone.js:14 Uncaught (in promise) RangeError: Maximum call stack size exceeded at String.toString (<anonymous>)...

Why is the generic expecting 3 options, although there is only one generic prop?

```ts import { type, scope } from "arktype"; const types = scope({ queryValue: "null | string | number | bigint | boolean",...

Is there an equivalent of zod.safeParse() for parsing incoming JSON requests?

Most people that I know that use Zod, use it mainly to parse incoming JSON request data into a schema. After reading through the docs I couldn't find anything that's really the equivalent of these methods, but wasn't sure if I'm just blind? Generic example: import { z } from 'zod'...

Has anyone been able to get `arktype` working in React Native/Expo?

I found this issue (https://github.com/arktypeio/arktype/issues/1027) but there doesn't seem to be any resolution (no pun intended...). I spent a couple hours trying different configurations but didn't have any luck. Just thought I would check if anyone has found a way to use arktype in a React Native project. Looks like a great library and I'd love to be able to pull it in....

scope() how to bypass circular reference error?

I've implemented with Scope() successfully circular references, but somehow, I hit a limitation as this one still throws a circular reference error: ```ts const types = scope({ queryValue: "namedDocument", // As soon as I add here namedDocument the error appears...

How to integrate generics with extend that need to access a type in scope?

queryValueObject is currently not resolving, and I assume it's because type() is creating its own scope. The question is, how can I solve it then? ```ts scope({ queryValue: [...

Is there a way to preserve jsdoc in arktype?

I have this piece of code: ``` /** * Defines a {@link https://docs.fauna.com/fauna/current/learn/security/roles/#user-defined-role | user-defined role}. A role determines an authentication secretā€™s privileges, which control data access....

What is the arktype 2 syntax for inferring classes with a private constructor?

In Arktype 1.x I was writing: ```ts import { type, Infer } from 'arktype'; ...

How to create an array of type.instanceOf?

This doesn't work: ```ts const documentReference = type.instanceOf(DocumentReference); scope({...

Validate Record values with morphs

Is it possible to do more advanced validation on Records? Ideally I'd like to apply any morph to each item in a Record. ```ts const nullNumber = type('number').pipe((s) => s ? Number(s) : null); ...

Testing a type in pipe

Congratulations on the 2.0 release, it's working great! šŸ˜€ Is it possible/best practice to run a type inside pipe? I'm having this test condition: ``` If string is a valid url, return URL Else return null...

configure({ onUndeclaredKey: 'delete' }) seems to allow extra properties through.

Or have I done something wrong ```typescript import { configure, type } from 'arktype' ...

Easier way to chain off of string.integer.parse?

I'm essentially trying to replicate this behavior from Zod:
const numberStringGreaterThan5 = z.coerce.number().gt(5)
numberStringGreaterThan5.parse("6")
const numberStringGreaterThan5 = z.coerce.number().gt(5)
numberStringGreaterThan5.parse("6")
...

Fail fast on union type

Hi i try to fail fast on union type as i know if there is an error , it's pointless to continue checking the union and get the right message and not the full list of all union message. For this i throw an error in the union branch and do a try catch on the type generated. Is there a clever/official way to do that: ```ts function arkTry<T extends (...args: unknown[]) => unknown>(fn: T) { return (...args: Parameters<T>): ReturnType<T> | ArkError => {...

Is ArkType compatible with the overrides made in `@total-typescript/reset`, or will stuff break?

This library overrides some TypeScript defaults for perhaps what could be considered more sensible defaults (I guess that's subjective). I'm wondering if could possibly break ArkType somehow? https://www.totaltypescript.com/ts-reset-article...

Zod "parity"? (nanoid, emoji,...)

Hello! ArkType is awesome! Been really enjoying replacing Zod in my project with it to try it out. šŸ˜ I won't assume this is the case but are there any plans to implement some of the nice little extra "features" Zod has such as its nanoid and/or emoji validations?...

How can I globally configure a subtypes error

Problem: I want to configure all ā€œstring.emailā€ errors to just be ā€œInvalid Emailā€. I can almost accomplish this, Iā€™m just missing a way to detect the subtype of the pattern at hand. Looking at the ctx object, code is just pattern. The closest thing I could do is match on the description, but that seems brittle. Zod seems to expose a .validation subtype to check on....
Next