Migration
Coming from Zod
Map jobs, not methods. Do not reproduce z.object in another spelling.
import { z } from 'zod'
const User = z.object({
name: z.string().min(1),
email: z.string().email().optional(),
})
import { string } from 'litetype'
const User = {
name: string.min(1),
'email?': string.email(),
}
| Job | Zod | litetype |
|---|---|---|
| Object | z.object({…}) | {…} |
| Optional key | .optional() | 'key?' |
| Undefined value | .optional() | .undefinable() |
| Extend / pick / omit | Library methods | Spread / property / rest |
| Infer | z.infer | Infer |
| Validate | Schema methods | parse, safeParse, check |
| Reject extras | .strict() | strict(shape) |
| Drop extras | Default | strip(shape) |
| Coerce | z.coerce.number() | coerce.number() |
| Cross-field check | .refine() | refine(shape, pred, message) |
Wrap only at the boundary
import { standard, string } from 'litetype'
export const User = { name: string.min(1), 'email?': string.email() }
export const UserInput = standard(User)
t.procedure.input(UserInput)
Do not port every feature. Use transforms for trim and brand, inspect issue.code instead of installing an error-map language, and skip Map, Set and Promise schemas unless your boundary genuinely receives them.