wip: zen
This commit is contained in:
parent
c87480cf93
commit
4ceabdffa0
156 changed files with 443 additions and 445 deletions
11
packages/console/core/src/util/fn.ts
Normal file
11
packages/console/core/src/util/fn.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import { z } from "zod"
|
||||
|
||||
export function fn<T extends z.ZodType, Result>(schema: T, cb: (input: z.infer<T>) => Result) {
|
||||
const result = (input: z.infer<T>) => {
|
||||
const parsed = schema.parse(input)
|
||||
return cb(parsed)
|
||||
}
|
||||
result.force = (input: z.infer<T>) => cb(input)
|
||||
result.schema = schema
|
||||
return result
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue