A Standard Schema v1 compliant schema instance
(any object that exposes a ['~standard'] property with version: 1
and a validate function).
import { z } from 'zod';
import { object, date, extern, InferType } from '@cleverbrush/schema';
const zodUser = z.object({ first: z.string(), last: z.string() });
const order = object({
user: extern(zodUser),
date: date(),
});
type Order = InferType<typeof order>;
// { user: { first: string; last: string }; date: Date }
order.validate({
user: { first: 'Alice', last: 'Smith' },
date: new Date(),
}); // { valid: true, object: { user: …, date: … } }
Wraps an external Standard Schema v1 compatible schema into a
@cleverbrush/schemabuilder.This enables cross-library schema composition — use schemas from Zod, Valibot, ArkType, or any Standard Schema v1 compliant library as properties inside
@cleverbrush/schemaobject schemas with full type inference.