Implement schema from type #781
-
Hi, Is there a way to type check schema implementation from an existing type? Something like this: import { type, union } from "arktype";
interface Owner {
name: string;
}
interface Dog {
name: string;
age: number;
owner?: Owner
}
// I would love to be able to create a schema from an existing type in a fully type safe way
const owner = type<Owner>({ name: 'string' });
const dog = type<Dog>({ age: 'integer>0', name: 'string', 'owner?': owner });
// for example this should error, because owner is not defined as possibly undefined
const dog = type<Dog>({ age: 'integer>0', name: 'string', owner }); Related issue from zod -> colinhacks/zod#372 |
Beta Was this translation helpful? Give feedback.
Answered by
ssalbdivad
Jun 3, 2023
Replies: 1 comment
-
This seems very useful! Created an issue for this. Let's continue the discussion there 👍 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
afoures
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This seems very useful! Created an issue for this.
Let's continue the discussion there 👍