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)...
Parse / validate urlencoded object
When posting something like {foo[a]: 1, foo[b]: 2}, is it possible to constrain the keys to always have a string and the value to always be a number? In the same move, is it possible to convert that to a mapped object like
qs
would too? (foo: {a: 1, b: 2}
)Is this the correct way to reference `root` in new scopes?
I'm working through using the scope/module interface, to define new app-specific helper keywords to use.
There are a couple of cases where I want to have a new hierarchy of keywords, but I don't want to duplicate the constraint from the "parent" in the child.
For instance, if I have something like (as a contrived example):...
Trying to use Arktype with nestjs module problems
I don't undestand why i'm getting problems with ...
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/kordian/Projects/kindora-backend/node_modules/.pnpm/arktype@2.1.20/node_modules/arktype/out/index.js from /Users/kordian/Projects/kindora-backend/dist/src/database/pagination.types.js not supported.
Instead change the require of index.js in /Users/kordian/Projects/kindora-backend/dist/src/database/pagination.types.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/Users/kordian/Projects/kindora-backend/dist/src/database/pagination.types.js:4:19) {
code: 'ERR_REQUIRE_ESM'
}
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/kordian/Projects/kindora-backend/node_modules/.pnpm/arktype@2.1.20/node_modules/arktype/out/index.js from /Users/kordian/Projects/kindora-backend/dist/src/database/pagination.types.js not supported.
Instead change the require of index.js in /Users/kordian/Projects/kindora-backend/dist/src/database/pagination.types.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/Users/kordian/Projects/kindora-backend/dist/src/database/pagination.types.js:4:19) {
code: 'ERR_REQUIRE_ESM'
}
Using ArkType with @google/genai
I had some trouble getting ArkType working with the latest Google AI SDK. Gemini complains about certain JSON Schema fields, so I had to remove them.
This seems to work for my use case:
```typescript
import { GoogleGenAI } from '@google/genai'...
Using an ArkType Generic within TS types.
How can I convert an ArkType generic to a TS generic? Something like:
...
export const SuccessResponse = type("<T>", { data: "T" });
export type SuccessResponse<T> = ??? // Goal: { data: T }
export const SuccessResponse = type("<T>", { data: "T" });
export type SuccessResponse<T> = ??? // Goal: { data: T }
Narrow inferIn vs inferOut
Maybe I misunderstood the expression, but I expected the In type to be
teamId: string | null
and the Out type to be teamId: string
. How can I achieve that, if not with narrow?
https://arktype.io/playground?code=import%2520%257B%2520type%2520%257D%2520from%2520%2522arktype%2522%250A%250Atype%2520In%2520%253D%2520typeof%2520Schema.inferIn%253B%250Atype%2520Out%2520%253D%2520typeof%2520Schema.inferOut%253B%250Aconst%2520Schema%2520%253D%2520type%28%257B%250A%2520%2520%2520%2520emails%253A%2520%2522string.email%255B%255D%2522%252C%250A%2520%2520%2520%2520teamId%253A%2520%255B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2522string%2520%257C%2520null%2522%252C%250A%2520%2520%2520%2520%2520%2520%2520%2520%2522%253A%2522%252C%250A%2520%2520%2520%2520%2520%2520%2520%2520%28str%252C%2520ctx%29%253A%2520str%2520is%2520NonNullable%253Ctypeof%2520str%253E%2520%253D%253E%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520str%2520%21%253D%2520null%2520%253F%2520true%2520%253A%2520ctx.mustBe%28%2522a%2520teamId%2522%29%252C%250A%2520%2520%2520%2520%255D%252C%250A%257D%29%253B...string.date.parse does not work on cyclic objects
Hello, i did not find anything related to this, but if i have a cyclic type like this:
```
export const types = scope({
User: {...
Multiple Error Message using Arktype
plateDefinition: {
rows: type('number>0').and(type('number<33')).configure({
message: 'Please enter an integer between 1 and 32.',
}),
...
toJsonSchema question
I am working on something that needs to convert standard schema validators to json schema. For seemingly similar validators, I am getting different behaviors between zod4's new json schema generatation and the arktype json schema generation that is leading to errors
```typescript
import { type } from "arktype";
import * as z4 from "zod/v4";...
Usage with JSON Schema
Hi all,
I'm in the process of migrating my project from Zod to ArkType, but I'm running into issues while converting my AI SDK tool input schemas.
The AI SDK requires non-Zod schemas to first be converted to JSON schema and be parsed with their
jsonSchema
helper, but when I do jsonSchema(arktypeSchema.toJsonSchema())
, I get the error:...handling fallback if error for regex
Is there any better way of doing default to undefined when failed one key in an object?
```typescript
type({
some_key: type("string").pipe((v) => myRegex.test(v) ? v : undefined)
})...
Unique attribute
Hi i created this schema to validate that a name is unique compared to existing name, however i wonder if it is possible to define the schema in a separate file and send the exiting names within the context
Thank you for your help
```
const existingNames = ["a", "b", "c"]...