@arkenv/core
ArkType-powered environment validation for TypeScript projects.
@arkenv/core is the ArkType validation engine. It exports arkenv()
and a type() that includes ArkType's keywords and
ArkEnv's. arktype is a required peer.
There are no runtime dependencies.
Writing Zod or Valibot?
Use @arkenv/standard instead. That keeps
arktype out of the tree.
Installation
Install the engine and its peer. The peer is required.
npm install @arkenv/core arktypeUsage
import from "@arkenv/core";
export const = ({
HOST: "string.host = 'localhost'",
PORT: "number.port = 3000",
DATABASE_URL: "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 = (
{ PORT: "number.port" },
{ : { PORT: "invalid" } },
);
if (!.) {
console.error(.);
}