0.1.2 #3
@@ -26,7 +26,7 @@ const exp = zodSchemaClass
|
|||||||
@exp.staticImplements
|
@exp.staticImplements
|
||||||
class User extends exp.extends implements Implements<typeof exp> {}
|
class User extends exp.extends implements Implements<typeof exp> {}
|
||||||
|
|
||||||
const inst = User.create({ id: 1n, name: "User" })
|
const inst = User.create({ id: 1n, name: "User" }, )
|
||||||
// console.log(inst.name)
|
// console.log(inst.name)
|
||||||
const instEffect = User.createEffect({ id: 1n, name: "User" })
|
const instEffect = User.createEffect({ id: 1n, name: "User" })
|
||||||
|
|
||||||
|
|||||||
@@ -4,12 +4,10 @@ import { z } from "zod"
|
|||||||
import { parseZodSchemaEffect } from "../util"
|
import { parseZodSchemaEffect } from "../util"
|
||||||
|
|
||||||
|
|
||||||
type ParseParamsArgs = [] | [params: Partial<z.ParseParams>]
|
type CreateArgs<Input extends object> = (
|
||||||
|
|
||||||
type NewZodSchemaInstanceArgs<Input extends object> = (
|
|
||||||
HasRequiredKeys<Input> extends true
|
HasRequiredKeys<Input> extends true
|
||||||
? [values: Input, ...args: ParseParamsArgs]
|
? [values: Input, params?: Partial<z.ParseParams>]
|
||||||
: [] | [values: Input, ...args: ParseParamsArgs]
|
: [] | [values: Input, params?: Partial<z.ParseParams>]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -55,7 +53,7 @@ export const ZodSchemaObject = <
|
|||||||
Class<Instance, [values: Values]> &
|
Class<Instance, [values: Values]> &
|
||||||
ImplStatic<typeof ZodSchemaObject>
|
ImplStatic<typeof ZodSchemaObject>
|
||||||
),
|
),
|
||||||
...[values, params]: NewZodSchemaInstanceArgs<PartialValues>
|
...[values, params]: CreateArgs<PartialValues>
|
||||||
) {
|
) {
|
||||||
return this
|
return this
|
||||||
.transform(this.schemaWithDefaultsValues)
|
.transform(this.schemaWithDefaultsValues)
|
||||||
@@ -69,7 +67,7 @@ export const ZodSchemaObject = <
|
|||||||
Class<Instance, [values: Values]> &
|
Class<Instance, [values: Values]> &
|
||||||
ImplStatic<typeof ZodSchemaObject>
|
ImplStatic<typeof ZodSchemaObject>
|
||||||
),
|
),
|
||||||
...[values, params]: NewZodSchemaInstanceArgs<PartialValues>
|
...[values, params]: CreateArgs<PartialValues>
|
||||||
) {
|
) {
|
||||||
return this
|
return this
|
||||||
.transform(this.schemaWithDefaultsValues)
|
.transform(this.schemaWithDefaultsValues)
|
||||||
@@ -83,7 +81,7 @@ export const ZodSchemaObject = <
|
|||||||
Class<Instance, [values: Values]> &
|
Class<Instance, [values: Values]> &
|
||||||
ImplStatic<typeof ZodSchemaObject>
|
ImplStatic<typeof ZodSchemaObject>
|
||||||
),
|
),
|
||||||
...[values, params]: NewZodSchemaInstanceArgs<PartialValues>
|
...[values, params]: CreateArgs<PartialValues>
|
||||||
) {
|
) {
|
||||||
return parseZodSchemaEffect(
|
return parseZodSchemaEffect(
|
||||||
this.transform(this.schemaWithDefaultsValues),
|
this.transform(this.schemaWithDefaultsValues),
|
||||||
|
|||||||
Reference in New Issue
Block a user