arktype

A

arktype

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

Join

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({});...

Mapping types

Hello, is it possible do to code like this? ```ts const x = type({ a: 'string', b: 'string',...

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

Error transforming object

I'm having some trouble doing transforming some data

Problem with Out type

Type '(In: string) => Out<bigint>' is not assignable to type 'bigint'
Type '(In: string) => Out<bigint>' is not assignable to type 'bigint'

Problem with validation in 2.0 dev?

I'm using 2.0.0-dev.11 and cannot figure out why some very basic validation fails. Short example: ```ts import { type } from "arktype"; ...

Referencing self

Hello, I have a type A ```ts const A = { hello: 'string', aArray: arrayOf(???)...

Export type to JSON and share it

Hello, I have two TS programs that should cooperate (A B), B import types and validates data, and A creates and "saves" the types. A rough idea ```ts // Program A import { type } from 'arktype' ...

Array error message

Hello, I think I found an inconsistency in array errors: https://stackblitz.com/edit/vy55da?file=type.ts The tags error is: tags must be at least 3 characters (was 2) But should probably not be characters, but something like items....

Unions with optional params?

Are unions with optional params supported in arktype? Example: ```typescript import { type, union } from "arktype"...

ParseError: '3.0' was parsed as a number but could not be narrowed to a literal value.

I'm not sure yet, where does this come from, but does it say anything to you? ``` /projects/custom/hfl/node_modules/arktype/dist/cjs/utils/errors.js:25 throw new ParseError(message); ^...

CJS/ESM issue with arktype

I installed arktype. It's a ESM thing, and it broke my building process. To fix it, I had to switch to building with babel and had to set these values in tsconfig.json:: ``` "module": "ES2015", "moduleResolution": "Bundler"...

The inferred type of '... cannot be named without a reference to '../../../../node_modules/arktype/

I receive this strange message:
src/clients/client-amazon.ts:76:3 - error TS2742: The inferred type of 'get' cannot be named without a reference to '../../../../node_modules/arktype/dist/types/scopes/type'. This is likely not portable. A type annotation is necessary.
src/clients/client-amazon.ts:76:3 - error TS2742: The inferred type of 'get' cannot be named without a reference to '../../../../node_modules/arktype/dist/types/scopes/type'. This is likely not portable. A type annotation is necessary.
...

Need help with typing scope output properly

I've got one crazy idea to declare types as scopes to access validators independently

non-empty string - how to?

How to declare a schema with 'string' type but... not empty, i.e. which is banning ""?

How to incorporate existing type?

I have a type imported from a third-party API and I'd like to build it in into my ark type: ```ts import { Foo } from 'fancy-api' const schema = type({...