@tsimpl/validation
v0.1.1
Published
Standard Schema types for tsimpl.
Readme
@tsimpl/validation
Standard Schema types for tsimpl and friends.
Use this when you want a stable shape for validators that can power runtime tagging and interop across libraries like Zod or Joi.
Why use it
- Shared schema contract (
~standard) across tools. - Pure TypeScript types, no runtime requirements.
- Works with
@tsimpl/runtimefor struct tagging.
Quick example
import type { StandardSchemaV1 } from "@tsimpl/validation";
type Input = { id: string };
type Output = { id: string; ok: true };
const schema: StandardSchemaV1<Input, Output> = {
"~standard": {
version: 1,
vendor: "example",
validate(value) {
if (value && typeof value === "object" && "id" in value) {
return { value: { id: String((value as Input).id), ok: true } };
}
return { issues: [{ message: "Expected Input." }] };
}
}
};Pair this schema with struct.name("Thing").define(schema) from @tsimpl/runtime to tag and validate values at runtime.
