由 Tobias W. 出售

ArkType is a high-performance TypeScript runtime validation library that parses optimized validators from familiar type-safe syntax, with full editor-to-runtime parity. Ideal for validating JSON payloads, forms, and external data at application boundaries.
ArkType is a TypeScript-first runtime validation and transformation library that parses type syntax directly from string literals, enabling schema definitions that mirror TypeScript types with near-zero overhead. It targets TypeScript developers who want strict, composable validation without code generation or decorator magic.
index.ts — Main re-export barrel; the single entry point for all public symbolsattributes.ts — Type utilities: distill, Out, comparators, regex/date literalsconfig.ts — Runtime configuration helpers and type exportsdeclare.ts — DeclarationParser for forward-declaring recursive or co-recursive typesfn.ts — FnParser / InternalFnParser for typed function schema definitionsgeneric.ts — Generic class and parser for parameterized type definitionsmatch.ts — MatchParser / CaseMatchParser for exhaustive pattern matchingmodule.ts — Module, BoundModule, Submodule for organizing type namespacesnary.ts — N-ary union and intersection parser type helpersscope.ts — scope, Scope, bindThis for creating isolated type registriestype.ts — Type class, the core runtime validator/transformer objectkeywords/ — Built-in keyword types: strings, numbers, arrays, dates, TypedArrays, constructorsparser/ — Internal string/AST/tuple parsers (not part of the public API surface)variants/ — Internal variant implementations for base, array, date, number, object, string typesnpm install arktype
npm install @ark/schema @ark/util arkregex
These are peer/internal packages that ArkType's source imports directly. If you are vendoring
ark/typesource rather than installingarktypefrom npm, all three must be present as named packages resolvable fromnode_modules.
启动隔离沙箱并在服务器端直接运行 — 无需本地配置。
此版本的 Tetrees AI Review
This TypeScript cli / script completed archive review. Structure, dependency manifests, documentation, functional source, and common risk patterns were checked by the Tetrees verification pipeline; runtime phases are stated separately.
Deterministic AVCP artifact review
管道 avcp-2026-08-04.1 · SHA-256 32d26a4c1e48286a…
This version-scoped review deterministically inspects the submitted archive for structure, dependencies, documentation, functional source, and common malicious or high-risk signals. Build and test phases are reported as passed only after an isolated sandbox audition. It is not a guarantee of perfect security.
审查日期 2026年8月4日
将此产品直接导入你的 AI IDE、网页构建器或云端 IDE。
将 Tetrees 连接到兼容的 AI IDE,列出你拥有的产品并获取已验证 ZIP,同时不会开放卖家上传权限。
暂无评价。
Sign in to join the discussion
Loading discussion…
Copy the contents of source/ into your project, e.g. src/arktype/.
Ensure tsconfig.json has strict mode and path aliases if you renamed the directory:
{
"compilerOptions": {
"strict": true,
"moduleResolution": "bundler",
"module": "ESNext",
"target": "ESNext",
"paths": {
"arktype": ["./src/arktype/index.ts"]
}
}
}
If you are importing directly from source rather than via npm, replace bare specifier imports (arktype) with relative paths or your configured alias throughout your codebase.
No environment variables are required. No native build steps, no pod install, no prebuild.
For Node.js 18+, ESM is recommended. Add "type": "module" to your package.json or use .mts extensions.
typeimport { type } from "arktype"
const MySchema = type({ name: "string", age: "number > 0" })
type MyType = typeof MySchema.infer
// => { name: string; age: number }
The primary entry point. Accepts string literals, object literals, and tuple expressions matching TypeScript syntax. Use it to define runtime validators that also carry full TypeScript inference.
scopeimport { scope } from "arktype"
const myScope = scope({
User: { name: "string", role: "Role" },
Role: "'admin' | 'viewer'"
})
const types = myScope.export()
Creates an isolated registry for mutually recursive or co-dependent type definitions. Use scope when types reference each other by name, or when you want a bounded namespace separate from the global ark registry.
Typeimport { Type } from "arktype"
declare const MyType: Type<{ id: string }>
const result = MyType({ id: "abc" }) // ArkErrors | { id: string }
The class returned by type(...). Instances are callable validators. Call them directly to validate data; the return is either the parsed/transformed value or an ArkErrors collection. Useful when you need to pass a validator as a value or extend it.
matchimport { match } from "arktype"
const classify = match
.in("string | number")
.when("string", s => `str:${s}`)
.when("number", n => n * 2)
.finalize()
Builds exhaustive discriminated-union handlers. .in() constrains the input type; .when() adds cases; .finalize() produces a callable. Use when replacing large if/switch chains that need type-safe narrowing.
distillimport type { distill, Out } from "arktype"
type Parsed = distill<string | Out<number>, "out">
// => number
A type-level utility that extracts the "in" or "out" face of a morphed type. Use in generic helpers when you need to reason about pre- or post-transformation shapes without instantiating a Type.
Parse and validate a plain object with nested constraints expressed in ArkType's string syntax. The validator infers the TypeScript type automatically.
import { type, ArkErrors } from "arktype"
const User = type({
id: "string.uuid",
email: "string.email",
age: "integer >= 18"
})
const result = User({ id: "not-a-uuid", email: "user@example.com", age: 25 })
if (result instanceof ArkErrors) {
for (const err of result) {
console.error(err.message)
}
} else {
console.log(result.id) // typed as string
}
Define mutually recursive types inside a scope so each alias can reference the others by name before they are fully defined.
import { scope, ArkErrors } from "arktype"
const types = scope({
Category: {
name: "string",
"subcategories?": "Category[]"
}
}).export()
const result = types.Category({
name: "Root",
subcategories: [{ name: "Child" }]
})
if (result instanceof ArkErrors) {
console.error(result.summary)
} else {
console.log(result.name) // "Root"
}
Use the pipe operator to validate input and transform it in one schema definition. The output type reflects the transformed shape.
import { type } from "arktype"
const ParsedDate = type("string").pipe(s => new Date(s), type("instanceof(Date)"))
const result = ParsedDate("2024-01-15")
if (result instanceof Date) {
console.log(result.getFullYear()) // 2024
}
Replace a switch/if chain with a type-safe exhaustive matcher that handles a union of inputs.
import { match } from "arktype"
const describe = match
.when("string", s => `String of length ${s.length}`)
.when("number", n => `Number: ${n}`)
.when("boolean", b => `Boolean: ${b}`)
.finalize()
console.log(describe("hello")) // "String of length 5"
console.log(describe(42)) // "Number: 42"
console.log(describe(true)) // "Boolean: true"
index.ts — Barrel re-exporting every public symbol; your import target.attributes.ts — Pure type-level helpers (distill, Out, Comparator, RegexLiteral) used throughout the inference layer.config.ts — Exports configuration types and helpers for customizing ArkType's global behavior.declare.ts — Exposes DeclarationParser for forward-referencing types in recursive schemas.fn.ts — FnParser wraps function schemas so argument/return types are validated at runtime.generic.ts — Generic and GenericParser enable parameterized, reusable type constructors.match.ts — MatchParser and CaseMatchParser implement the chainable pattern-matching DSL.module.ts — Module / BoundModule / Submodule organize exported scope aliases into typed namespaces.nary.ts — Type-level N-ary union/intersection/pipe helpers used internally by type.scope.ts — scope() factory and Scope class; the isolated registry for multi-type definitions.type.ts — Type class definition: the callable validator object with .pipe, .narrow, .assert, etc.keywords/ — Built-in primitive and prototype keywords (string.email, number.integer, Array, etc.).parser/ — Internal string parser, AST reduction, and tuple expression handling; not imported directly.variants/ — Internal per-type-flavor implementations (array, date, number, object, string); not imported directly.moduleResolution must be "bundler" or "node16" — ArkType source uses .ts extensions in imports; older "node" resolution will fail to resolve them. Set "moduleResolution": "bundler" in tsconfig.json.@ark/schema and @ark/util must be the exact same version as the vendored source — Version mismatches cause silent type errors or runtime crashes. Pin all three to matching releases.type(...) outside a scope uses the global ark registry — If you define aliases with declare and forget to call .export() on a scope, resolution fails at runtime with a missing alias error. Always call scope({...}).export().ArkErrors is iterable, not a plain Error — Checking result instanceof Error will miss validation failures. Always check result instanceof ArkErrors before accessing .summary or iterating."stirng" produce runtime ParseError throws, not TypeScript errors unless you use the typed overloads. Prefer object-literal syntax for IDE autocomplete.require("arktype") only works when the installed npm package provides a CJS build. Vendoring the raw source requires an ESM-capable bundler or ts-node --esm.I have vendored the ArkType TypeScript validation library into my project under `src/arktype/`.
The integration guide is in `USAGE.md` next to this message.
The upstream package is `arktype` (npm).
Please help me integrate ArkType into my existing project step by step:
1. Read `USAGE.md` and `source/index.ts` to understand all available exports.
2. Identify where I currently do manual runtime validation or use zod/yup/joi.
3. Replace those validators with equivalent `type(...)` or `scope(...)` definitions
using real ArkType syntax from the docs.
4. Add `ArkErrors` handling where validators are called, replacing any try/catch
or manual error objects.
5. If I have mutually recursive types, wrap them in `scope({}).export()`.
6. Update my `tsconfig.json` `paths` so `arktype` resolves to `src/arktype/index.ts`.
7. Show the final diff for each changed file and confirm TypeScript compiles cleanly.
My project is: [DESCRIBE YOUR PROJECT HERE]
Files that need validation: [LIST FILES OR PASTE CODE]
ArkType is released under the MIT License. See source/LICENSE if present, or refer to the arktype npm package and the official repository for the authoritative license text and changelog.
This product’s unique contribution is clean room implementation of valuable code block into AVCP compatible standard.
完整安装指南与集成提示词将在购买后解锁。
SaaS, AI & Subscription Products
免费