Working extendable
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Julien Valverdé
2024-02-08 18:26:37 +01:00
parent 041b3f566e
commit 5f7fd30459
4 changed files with 55 additions and 11 deletions

View File

@@ -1,11 +1,31 @@
import { abstract, trait } from "@thilawyn/traitify-ts"
import { Effect, pipe } from "effect"
import { HasRequiredKeys } from "type-fest"
import { z } from "zod"
import { NewZodSchemaInstanceArgs, NewZodSchemaInstanceInput } from ".."
import { ZodSchemaClass } from "../types/ZodSchemaClass"
import { parseZodTypeEffect } from "../util"
type NewZodSchemaInstanceInput<
Values extends {},
DefaultValues extends Partial<Values>,
> = {
[Key in Exclude<keyof Values, keyof DefaultValues>]: Values[Key]
} & {
[Key in keyof DefaultValues]?: Key extends keyof Values
? Values[Key]
: never
}
type ParseParamsArgs = [] | [params: Partial<z.ParseParams>]
type NewZodSchemaInstanceArgs<Input extends object> = (
HasRequiredKeys<Input> extends true
? [values: Input, ...args: ParseParamsArgs]
: [] | [values: Input, ...args: ParseParamsArgs]
)
export const InstantiableZodSchemaObject = trait(
abstract(),