-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2fc581f
commit fe1623b
Showing
56 changed files
with
1,455 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
dev/arktype.io/versioned_docs/version-1.0.29-alpha/api.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
id: api | ||
hide_table_of_contents: true | ||
title: API | ||
--- | ||
|
||
# API | ||
|
||
<!-- @blockFrom:README.md:api |> replace(./dev/test,https://github.com/arktypeio/arktype/tree/main/dev/test) --> | ||
|
||
ArkType supports many of TypeScript's built-in types and operators, as well as some new ones dedicated exclusively to runtime validation. In fact, we got a little ahead of ourselves and built a ton of cool features, but we're still working on getting caught up syntax and API docs. Keep an eye out for more in the next couple weeks ⛵ | ||
|
||
In the meantime, check out the examples here and use the type hints you get to learn how you can customize your types and scopes. If you want to explore some of the more advanced features, take a look at [our unit tests](https://github.com/arktypeio/arktype/tree/main/dev/test) or ask us [on Discord](https://discord.gg/xEzdc3fJQC) if your functionality is supported. If not, [create a GitHub issue](https://github.com/arktypeio/arktype/issues/new) so we can prioritize it! | ||
|
||
<!-- @blockEnd --> |
11 changes: 11 additions & 0 deletions
11
dev/arktype.io/versioned_docs/version-1.0.29-alpha/api/ark.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
hide_table_of_contents: true | ||
--- | ||
|
||
# ark | ||
|
||
## text | ||
|
||
```ts | ||
ark: Space<PrecompiledDefaults> | ||
``` |
54 changes: 54 additions & 0 deletions
54
dev/arktype.io/versioned_docs/version-1.0.29-alpha/api/arkscope.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
hide_table_of_contents: true | ||
--- | ||
|
||
# arkScope | ||
|
||
## text | ||
|
||
```ts | ||
arkScope: import("./scope.js").Scope< | ||
[ | ||
{ | ||
any: any | ||
bigint: bigint | ||
boolean: boolean | ||
false: false | ||
never: never | ||
null: null | ||
number: number | ||
object: object | ||
string: string | ||
symbol: symbol | ||
true: true | ||
unknown: unknown | ||
void: void | ||
undefined: undefined | ||
Function: (...args: any[]) => unknown | ||
Date: Date | ||
Error: Error | ||
Map: Map<unknown, unknown> | ||
RegExp: RegExp | ||
Set: Set<unknown> | ||
WeakMap: WeakMap<object, unknown> | ||
WeakSet: WeakSet<object> | ||
Promise: Promise<unknown> | ||
alpha: string | ||
alphanumeric: string | ||
lowercase: string | ||
uppercase: string | ||
creditCard: string | ||
email: string | ||
uuid: string | ||
parsedNumber: (In: string) => Out<number> | ||
parsedInteger: (In: string) => Out<number> | ||
parsedDate: (In: string) => Out<Date> | ||
semver: string | ||
json: (In: string) => Out<unknown> | ||
integer: number | ||
}, | ||
{}, | ||
false | ||
] | ||
> | ||
``` |
24 changes: 24 additions & 0 deletions
24
dev/arktype.io/versioned_docs/version-1.0.29-alpha/api/arrayof.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
hide_table_of_contents: true | ||
--- | ||
|
||
# arrayOf | ||
|
||
## operator | ||
|
||
- [arrayOf](./arrayof.md) | ||
|
||
## string | ||
|
||
- "T[]" <br/> | ||
- const numberArray = type("number[]")<br/> | ||
|
||
## tuple | ||
|
||
- [T, "[]"] <br/> | ||
- const tupleArray = type(["number", "[]"])<br/> | ||
|
||
## helper | ||
|
||
- arrayOf(T) <br/> | ||
- const helperArray = arrayOf("number")<br/> |
13 changes: 13 additions & 0 deletions
13
dev/arktype.io/versioned_docs/version-1.0.29-alpha/api/infer.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
hide_table_of_contents: true | ||
--- | ||
|
||
# Infer | ||
|
||
## text | ||
|
||
```ts | ||
export type Infer<t> = { | ||
[as]?: t | ||
} | ||
``` |
23 changes: 23 additions & 0 deletions
23
dev/arktype.io/versioned_docs/version-1.0.29-alpha/api/inferdefinition.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
hide_table_of_contents: true | ||
--- | ||
|
||
# inferDefinition | ||
|
||
## text | ||
|
||
```ts | ||
export type inferDefinition<def, $> = isAny<def> extends true | ||
? never | ||
: def extends Infer<infer t> | InferredThunk<infer t> | ||
? t | ||
: def extends string | ||
? inferString<def, $> | ||
: def extends List | ||
? inferTuple<def, $> | ||
: def extends RegExp | ||
? string | ||
: def extends Dict | ||
? inferRecord<def, $> | ||
: never | ||
``` |
19 changes: 19 additions & 0 deletions
19
dev/arktype.io/versioned_docs/version-1.0.29-alpha/api/instanceof.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
hide_table_of_contents: true | ||
--- | ||
|
||
# instanceOf | ||
|
||
## operator | ||
|
||
- [instanceOf](./instanceof.md) | ||
|
||
## tuple | ||
|
||
- ["instanceOf", T] <br/> | ||
- const tupleInstanceOf = type(["instanceOf", Date])<br/> | ||
|
||
## helper | ||
|
||
- instanceOf(T) <br/> | ||
- const helperInstanceOf = instanceOf(Date)<br/> |
24 changes: 24 additions & 0 deletions
24
dev/arktype.io/versioned_docs/version-1.0.29-alpha/api/intersection.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
hide_table_of_contents: true | ||
--- | ||
|
||
# intersection | ||
|
||
## operator | ||
|
||
- [&](./intersection.md) | ||
|
||
## string | ||
|
||
- "L&R" <br/> | ||
- const intersection = type("/@arktype\.io$/ & email")<br/> | ||
|
||
## tuple | ||
|
||
- [L, "&", R] <br/> | ||
- const tupleIntersection = type(["/@arktype\.io$/", "&", "email"])<br/> | ||
|
||
## helper | ||
|
||
- intersection(L,R) <br/> | ||
- const helperIntersection = intersection("/@arktype\.io$/","email")<br/> |
19 changes: 19 additions & 0 deletions
19
dev/arktype.io/versioned_docs/version-1.0.29-alpha/api/jsobjectsscope.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
hide_table_of_contents: true | ||
--- | ||
|
||
# jsObjectsScope | ||
|
||
## text | ||
|
||
| Name | Type | Description | | ||
| -------- | ------------------------------ | ----------- | | ||
| Function | ` (...args: any[]) => unknown` | | | ||
| Date | ` Date` | | | ||
| Error | ` Error` | | | ||
| Map | ` Map<unknown, unknown>` | | | ||
| RegExp | ` RegExp` | | | ||
| Set | ` Set<unknown>` | | | ||
| WeakMap | ` WeakMap<object, unknown>` | | | ||
| WeakSet | ` WeakSet<object>` | | | ||
| Promise | ` Promise<unknown>` | | |
19 changes: 19 additions & 0 deletions
19
dev/arktype.io/versioned_docs/version-1.0.29-alpha/api/keyof.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
hide_table_of_contents: true | ||
--- | ||
|
||
# keyOf | ||
|
||
## operator | ||
|
||
- [keyOf](./keyof.md) | ||
|
||
## tuple | ||
|
||
- "["keyOf", T]" <br/> | ||
- const tupleKeyOf = type(["keyOf", {a:"string"}])<br/> | ||
|
||
## helper | ||
|
||
- keyOf(T) <br/> | ||
- const helperKeyOf = keyOf({a:"string"})<br/> |
56 changes: 56 additions & 0 deletions
56
dev/arktype.io/versioned_docs/version-1.0.29-alpha/api/keywords.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
hide_table_of_contents: true | ||
--- | ||
|
||
# Keywords | ||
|
||
## jsObjectsScope | ||
|
||
| Name | Type | Description | | ||
| -------- | ------------------------------ | ----------- | | ||
| Function | ` (...args: any[]) => unknown` | | | ||
| Date | ` Date` | | | ||
| Error | ` Error` | | | ||
| Map | ` Map<unknown, unknown>` | | | ||
| RegExp | ` RegExp` | | | ||
| Set | ` Set<unknown>` | | | ||
| WeakMap | ` WeakMap<object, unknown>` | | | ||
| WeakSet | ` WeakSet<object>` | | | ||
| Promise | ` Promise<unknown>` | | | ||
|
||
## tsKeywordsScope | ||
|
||
| Name | Type | Description | | ||
| --------- | ------------ | ----------- | | ||
| any | ` any` | any | | ||
| bigint | ` bigint` | a bigint | | ||
| boolean | ` boolean` | a boolean | | ||
| false | ` false` | false | | ||
| never | ` never` | never | | ||
| null | ` null` | null | | ||
| number | ` number` | a number | | ||
| object | ` object` | an object | | ||
| string | ` string` | a string | | ||
| symbol | ` symbol` | a symbol | | ||
| true | ` true` | true | | ||
| unknown | ` unknown` | unknown | | ||
| void | ` void` | void | | ||
| undefined | ` undefined` | undefined | | ||
|
||
## validationScope | ||
|
||
| Name | Type | Description | | ||
| ------------- | ------------------------------------------------------------------ | ---------------------------- | | ||
| alpha | ` string` | only letters | | ||
| alphanumeric | ` string` | only letters and digits | | ||
| lowercase | ` string` | only lowercase letters | | ||
| uppercase | ` string` | only uppercase letters | | ||
| creditCard | ` string` | a valid credit card number | | ||
| email | ` string` | a valid email | | ||
| uuid | ` string` | a valid UUID | | ||
| parsedNumber | ` (In: string) => import("../../parse/ast/morph.js").Out<number>` | a well-formed numeric string | | ||
| parsedInteger | ` (In: string) => import("../../parse/ast/morph.js").Out<number>` | a well-formed integer string | | ||
| parsedDate | ` (In: string) => import("../../parse/ast/morph.js").Out<Date>` | a valid date | | ||
| semver | ` string` | a valid semantic version | | ||
| json | ` (In: string) => import("../../parse/ast/morph.js").Out<unknown>` | a JSON-parsable string | | ||
| integer | ` number` | an integer | |
19 changes: 19 additions & 0 deletions
19
dev/arktype.io/versioned_docs/version-1.0.29-alpha/api/morph.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
hide_table_of_contents: true | ||
--- | ||
|
||
# morph | ||
|
||
## operator | ||
|
||
- [|>](./morph.md) | ||
|
||
## tuple | ||
|
||
- [inputType, "|>", (data) => output] <br/> | ||
- const tupleMorph = type( ["string", "|>" , (data) => \`morphed ${data}\`])<br/> | ||
|
||
## helper | ||
|
||
- morph(inputType, (data) => output) <br/> | ||
- const helperMorph = morph("string", (data) => \`morphed ${data}\`)<br/> |
18 changes: 18 additions & 0 deletions
18
dev/arktype.io/versioned_docs/version-1.0.29-alpha/api/narrow.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
hide_table_of_contents: true | ||
--- | ||
|
||
# narrow | ||
|
||
## operator | ||
|
||
- [=>](./narrow.md) | ||
|
||
## tuple | ||
|
||
- ["type", "=>" , condition] <br/> | ||
- const narrow = type( ["number", "=>" , (n) => n % 2 === 0])<br/> | ||
|
||
## example | ||
|
||
- const isEven = (x: unknown): x is number => x % 2 === 0 |
22 changes: 22 additions & 0 deletions
22
dev/arktype.io/versioned_docs/version-1.0.29-alpha/api/operators.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
hide_table_of_contents: true | ||
--- | ||
|
||
# Operators | ||
|
||
## Operating Table | ||
|
||
| operator | string | tuple | helper | | ||
| ----------------------------- | ---------------------------------------------------------- | ---------------------------------------- | ---------------------------------- | | ||
| [arrayOf](./arrayof.md) | "T[]" | [T, "[]"] | arrayOf(T) | | ||
| [instanceOf](./instanceof.md) | | ["instanceOf", T] | instanceOf(T) | | ||
| [&](./intersection.md) | "L&R" | [L, "&", R] | intersection(L,R) | | ||
| [keyOf](./keyof.md) | | "["keyOf", T]" | keyOf(T) | | ||
| [|>](./morph.md) | | [inputType, "|>", (data) => output] | morph(inputType, (data) => output) | | ||
| [=>](./narrow.md) | | ["type", "=>" , condition] | | | ||
| [|](./union.md) | "L|R" | [L, "|" , R] | union(L,R) | | ||
| [===](./valueof.md) | | ["===", T] | valueOf(T) | | ||
| [:](./parseconfigtuple.md) | | ["type", ":", config] | | | ||
| [bound](./validatebound.md) | "N<S<N", with comparators restricted to < or <= | | | | ||
| [%](./validatedivisor.md) | "N%D", where "N" is a number and "D" is a non-zero integer | | | | ||
| [node](./resolvednode.md) | | ["node", nodeDefinition] | type.from(nodeDefinition) | |
Oops, something went wrong.