-
Notifications
You must be signed in to change notification settings - Fork 5
Make ArkType optional (Built-in Standard Schema) through explicit validator mode #723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
yamcodes
merged 68 commits into
main
from
722-make-arktype-optional-and-use-standard-schema-directly
Jan 16, 2026
Merged
Changes from all commits
Commits
Show all changes
68 commits
Select commit
Hold shift + click to select a range
a8f5f61
docs(validator): add explicit mode design docs
yamcodes 1201d6f
docs(design): add non-goals for validator mode
yamcodes 213fe31
feat: Refine and expand the task list for explicit validator mode imp…
yamcodes 6ba7322
docs: Refine design document for explicit validator mode, detailing A…
yamcodes a35a74e
feat: add requirements for explicit error handling in standard valida…
yamcodes 22abf0b
feat: Add explicit `validator` mode to `ArkEnvConfig` for `arktype` o…
yamcodes 3ff8a01
docs: detail the design for an explicit `validator` option in `create…
yamcodes e8bfac8
feat: Refine `standard` validator mode specification by clarifying co…
yamcodes 5f1dcc9
feat: Dynamically show send button and prevent sending empty or compo…
yamcodes d8e3e5c
Refine the explicit validator mode proposal by clarifying its rationa…
yamcodes 03e5549
Merge branch 'main' into 722-make-arktype-optional-and-use-standard-s…
yamcodes b5decc8
feat: introduce explicit validator mode
yamcodes 2638105
refactor: separate `indent` and `styleText` utilities into individual…
yamcodes 54200f3
[autofix.ci] apply automated fixes
autofix-ci[bot] 3ee8017
feat: implement explicit validator mode with dispatcher, refactor Ark…
yamcodes 98e35e4
refactor: Extract ArkType scope definitions into variables and adjust…
yamcodes dd0dc95
refactor: Refine ArkType proxy to use `$.type` for type access and ad…
yamcodes c787cef
fix: Correctly identify ArkType errors using `isArkErrors` and enhanc…
yamcodes f747089
feat: Complete implementation tasks for the explicit validator mode, …
yamcodes 4578bfa
feat: Implement lazy loading for ArkType and its scope/keywords to im…
yamcodes 88ae425
refactor: rename `lazyKeyword` to `keyword` and refine its type signa…
yamcodes 541b50d
feat: Make ArkType an optional peer dependency and refactor internal …
yamcodes 25495fc
feat: Integrate ArkType custom scope keywords directly into Arkenv, r…
yamcodes 8d10fa2
feat: add `without-arktype` example and enhance `with-standard-schema…
yamcodes f0aadd0
chore: Add 'without-arktype' example folder to the workspace configur…
yamcodes 1b6c9ad
Modify `HOST` environment variable definition to accept IP addresses …
yamcodes ac7bd40
refactor: Standardize schema examples to use Zod exclusively and upda…
yamcodes 72a8cdd
feat: Enhance environment variable parsing by using `z.coerce.number(…
yamcodes c5541df
chore: Add `validator: "standard"` option to the `createEnv` function…
yamcodes 62baf37
deps: update arkenv dependency version.
yamcodes 10ec95e
docs: Rephrase explicit non-goals for improved clarity and prescripti…
yamcodes f6be7fe
refactor: remove `StandardValidator` type and update `parseStandard` …
yamcodes 253c1c5
feat: Add standard-schema types and a Dict helper, and refine arktype…
yamcodes c5bf4dc
feat: enhance `InferType` to support `{ t: U }` pattern and utilize `…
yamcodes df54547
refactor: update type import from `arktype` to `@repo/scope`'s `$` ob…
yamcodes 5076970
refactor(arkenv): Use shared StandardSchemaV1 type
yamcodes 03c5732
refactor: Reorder conditional types in `InferType` to prioritize func…
yamcodes 8262d4f
Merge branch 'main' into 722-make-arktype-optional-and-use-standard-s…
yamcodes 54d5c19
docs: update reported bundle size
yamcodes 4954c2e
feat(types): add standard schema and helpers
yamcodes e2e2975
feat(arkenv): make ArkType optional with new validator option
yamcodes 275dc1a
docs(arkenv): enhance coercion and installation instructions
yamcodes a99bd2f
docs(arkenv): streamline Standard Schema documentation
yamcodes e81ff0e
Merge branch 'main' into 722-make-arktype-optional-and-use-standard-s…
yamcodes 2e237d6
feat: Make ArkType an optional dependency by dynamically loading it a…
yamcodes e921685
chore: Reorder imports for consistency across several files.
yamcodes 341edb0
refactor: move schema definition logic to a separate `arkenv/arktype`…
yamcodes 1bc4c6a
chore: Refine vite-plugin Vitest alias resolution for `arkenv` and `a…
yamcodes 1f7a26f
chore: Reordered `@repo/types` and `@repo/scope` in `devDependencies`.
yamcodes f858f6c
feat: Make ArkType an optional peer dependency, move the `type` expor…
yamcodes 1595a53
docs: Clarify that helpers imported from `arkenv/arktype` are 'ArkTyp…
yamcodes da5dcc5
docs: Separate arkenv and arktype imports in the vite config example.
yamcodes ed40bdf
refactor: Remove keywords export from the scope package.
yamcodes e0c5048
Remove `@types/node` dependency and its TypeScript configuration, alo…
yamcodes 842feca
refactor: update `type` import path to `arkenv/arktype` in example co…
yamcodes ba7ff43
feat: add CommonJS search paths for arktype module loading
yamcodes 089a3b4
feat: add runtime validation for Standard Schema in createEnv function
yamcodes ca51f08
fix: update PORT and DEBUG validation to use coercion in standard schema
yamcodes b3def59
fix: use coercion for PORT validation in standard schema
yamcodes aa1b9b9
feat: introduce and document validator mode, clarifying coercion and …
yamcodes b71e26c
feat: Add documentation for ArkEnv's `arktype` and `standard` validat…
yamcodes 93c4b17
fix: Update internal documentation links to use absolute paths.
yamcodes 57d66e7
docs: add note on ArkType usage in quickstart and update IDE integrat…
yamcodes 7b6936e
feat: Add ArkType-based type coercion for environment variables, supp…
yamcodes c2e50b0
[autofix.ci] apply automated fixes
autofix-ci[bot] 3affdf6
docs: Update ArkType mode hyphenation and validator mode icon.
yamcodes 3a57eab
docs: Remove 'New' icon from validator-mode MDX and update its naviga…
yamcodes 288df49
refactor: remove arktype dependency and switch to standard validator …
yamcodes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
| --- | ||
| "arkenv": minor | ||
| --- | ||
|
|
||
| #### ArkType is now an optional peer dependency | ||
|
|
||
| To achieve a true zero-dependency core, ArkType is now an optional peer dependency. | ||
|
|
||
| - **Breaking Change**: The `type` export has been moved from the main `arkenv` entry point to `arkenv/arktype`. | ||
|
|
||
| ```ts | ||
| // ❌ Before | ||
| import { type } from "arkenv"; | ||
|
|
||
| // ✅ After | ||
| import { type } from "arkenv/arktype"; | ||
| ``` | ||
|
|
||
| - **Explicit Validator Modes**: ArkEnv now supports an explicit `validator` option. | ||
|
|
||
| - **`validator: "arktype"` (default)**: Uses ArkType for validation and coercion. Requires `arktype` to be installed. | ||
| - **`validator: "standard"`**: Uses Standard Schema validators directly (e.g., Zod, Valibot). Works without ArkType. | ||
|
|
||
| Existing usage of `arkenv()` remains unchanged when ArkType is installed. Projects using ArkType features must now explicitly install `arktype` and import ArkType-land helpers from `arkenv/arktype`. |
This file contains hidden or 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,5 @@ | ||
| --- | ||
| "@repo/types": patch | ||
| --- | ||
|
|
||
| #### Added Standard Schema, helpers |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -46,7 +46,7 @@ coverage/ | |
| esbuild-why*.html | ||
|
|
||
| # arktype clone | ||
| arktype/ | ||
| /arktype/ | ||
|
|
||
| # explicitly ignored folder | ||
| ignore-me/ | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,46 +1,45 @@ | ||
| import arkenv, { type } from "arkenv"; | ||
| import arkenv from "arkenv"; | ||
| import * as z from "zod"; | ||
|
|
||
| const env = arkenv({ | ||
| // ArkType validators (concise TypeScript-like syntax) | ||
| HOST: "string.host", | ||
| PORT: "number.port", | ||
| NODE_ENV: "'development' | 'production' | 'test' = 'development'", | ||
| DEBUG: "boolean = false", | ||
| const env = arkenv( | ||
| { | ||
| // Zod validators (great for complex validation and transformations) | ||
| DATABASE_URL: z.string().url(), | ||
| API_KEY: z | ||
| .string() | ||
| .min(32) | ||
| .describe("API key must be at least 32 characters"), | ||
|
|
||
| // Zod validators (great for complex validation and transformations) | ||
| DATABASE_URL: z.url(), | ||
| API_KEY: z | ||
| .string() | ||
| .min(32) | ||
| .describe("API key must be at least 32 characters"), | ||
| // Standard Schema compatible validators | ||
| MAX_RETRIES: z.coerce.number().int().positive().default(3), | ||
| TIMEOUT_MS: z.coerce.number().int().min(0).max(30000).default(5000), | ||
|
|
||
| // Mix them together based on your needs | ||
| MAX_RETRIES: z.number().int().positive().default(3), | ||
| TIMEOUT_MS: z.number().int().min(0).max(30000).default(5000), | ||
| // Complex transformations with Zod | ||
| ALLOWED_ORIGINS: z | ||
| .string() | ||
| .transform((str: string) => str.split(",")) | ||
| .pipe(z.array(z.string().url())), | ||
|
|
||
| // Complex transformations with Zod | ||
| ALLOWED_ORIGINS: z | ||
| .string() | ||
| .transform((str: string) => str.split(",")) | ||
| .pipe(z.array(z.url())), | ||
|
|
||
| // Array defaults with ArkType | ||
| FEATURE_FLAGS: type("string[]").default(() => []), | ||
| }); | ||
| NODE_ENV: z | ||
| .enum(["development", "production", "test"]) | ||
| .default("development"), | ||
| DEBUG: z | ||
| .union([z.boolean(), z.enum(["true", "false", "1", "0"])]) | ||
| .transform((v) => v === true || v === "true" || v === "1") | ||
| .default(false), | ||
| }, | ||
| { validator: "standard" }, | ||
| ); | ||
|
|
||
| // All validators work together seamlessly with full type inference | ||
| console.log({ | ||
| host: env.HOST, | ||
| port: env.PORT, | ||
| nodeEnv: env.NODE_ENV, | ||
| debug: env.DEBUG, | ||
| databaseUrl: env.DATABASE_URL, | ||
| apiKey: `${env.API_KEY.substring(0, 8)}...`, // Don't log full API key | ||
| maxRetries: env.MAX_RETRIES, | ||
| timeoutMs: env.TIMEOUT_MS, | ||
| allowedOrigins: env.ALLOWED_ORIGINS, | ||
| featureFlags: env.FEATURE_FLAGS, | ||
| }); | ||
|
|
||
| export default env; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.