@kbml-tentacles/forms-arktype
v3.0.0
Published
Arktype validation adapter for @kbml-tentacles/forms.
Maintainers
Readme
@kbml-tentacles/forms-arktype
ArkType validation adapter for @kbml-tentacles/forms. Plug an ArkType schema into a field validator — error paths, codes, and messages flow through unchanged.
npm install arktype @kbml-tentacles/core @kbml-tentacles/forms @kbml-tentacles/forms-arktypeQuick start
import { type } from "arktype";
import { createFormContract } from "@kbml-tentacles/forms";
import { arktype } from "@kbml-tentacles/forms-arktype";
const contract = createFormContract()
.field("email", (f) =>
f<string>().default("").validate(arktype(type("string.email"))),
)
.field("age", (f) =>
f<number>().default(0).validate(arktype(type("number>=18"))),
);API
arktype(schema)— sync validator from any ArkType schema (the function returned bytype(...)). ArkType is sync-first, so no async variant is needed; use a plain.validateAsync(async (v) => ...)if you need to combine with an async check.
Documentation
- How-to: use a schema validator
- Reference:
docs/reference/validators
Peer dependencies
arktype >=2.0@kbml-tentacles/core ^1.0.0@kbml-tentacles/forms ^1.0.0
License
MIT © Nikita Lumpov
