Standard Schema types for tsimpl.
npm install @tsimpl/validationStandard 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.
- Shared schema contract (~standard) across tools.
- Pure TypeScript types, no runtime requirements.
- Works with @tsimpl/runtime for struct tagging.
``ts
import type { StandardSchemaV1 } from "@tsimpl/validation";
type Input = { id: string };
type Output = { id: string; ok: true };
const schema: StandardSchemaV1 = {
"~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.