@arkenv/core
ArkType-powered environment validation for TypeScript projects.
@arkenv/core is the ArkType validation engine. It exports arkenv()
and a type() function which includes all of ArkType's keywords and additional ones. arktype is a required peer. There are no runtime dependencies.
- If you use ArkType, use
@arkenv/core. It also supports Zod and Valibot. You do not need to install both engines. - If you don't use ArkType, use
@arkenv/standard. This will keep your tree free of thearktypedependency.
Installation
npm install @arkenv/core arktypepnpm add @arkenv/core arktypeyarn add @arkenv/core arktypebun install @arkenv/core arktypeUsage
import from "@arkenv/core";
export const = ({
: "string.host = 'localhost'",
: "number.port = 3000",
: "string",
});Exports
The main entry is the throw-path runtime. Issue helpers and the non-throwing parser live on subpaths so the default import stays small.
| Export | Kind | Role |
|---|---|---|
arkenv | function (default + named) | Validate and return a typed env object |
type | function | ArkType type with keywords |
ArkEnvError | class | Thrown on validation failure |
ArkEnvConfig | type | Options object |
EnvSchema | type | Declarative schema map |
Infer | type | Infer output from a schema |
SafeArkEnvResult | type | Result shape returned by @arkenv/core/safe |
Subpaths
Issue formatting and the non-throwing parser are separate entries.
| Import | Role |
|---|---|
@arkenv/core | Throw-path arkenv() and type() |
@arkenv/core/issues | formatIssues, getSchemaKeys, and EnvIssue / EnvIssueCode / EnvIssueMeta |
@arkenv/core/safe | arkenv — result object instead of a throw (default + named export) |
import from "@arkenv/core/safe";
const = (
{ : "number.port" },
{ : { : "invalid" } },
);
if (!.) {
.(.);
}