ExtendableZodSchemaObject work
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
39
src/traits/ExtendableZodSchemaObject.ts
Normal file
39
src/traits/ExtendableZodSchemaObject.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { abstract, trait } from "@thilawyn/traitify-ts"
|
||||
import { z } from "zod"
|
||||
import { ZodSchemaAbstractClass } from "../types/ZodSchemaClass"
|
||||
|
||||
|
||||
export const ExtendableZodSchemaObject = trait(
|
||||
abstract(),
|
||||
|
||||
Super => class ExtendableZodSchemaObject extends Super {
|
||||
static extend<
|
||||
Super extends ZodSchemaAbstractClass<SuperSchemaT, SuperSchemaUnknownKeys, SuperSchemaCatchall, SuperValues, SuperDefaultValues>,
|
||||
|
||||
SuperSchemaT extends z.ZodRawShape,
|
||||
SuperSchemaUnknownKeys extends z.UnknownKeysParam,
|
||||
SuperSchemaCatchall extends z.ZodTypeAny,
|
||||
SuperValues extends {},
|
||||
SuperDefaultValues extends Partial<SuperValues>,
|
||||
|
||||
SchemaT extends z.ZodRawShape,
|
||||
SchemaUnknownKeys extends z.UnknownKeysParam,
|
||||
SchemaCatchall extends z.ZodTypeAny,
|
||||
Values extends SuperValues,
|
||||
DefaultValues extends Partial<Values>,
|
||||
>(
|
||||
this: Super | ZodSchemaAbstractClass<SuperSchemaT, SuperSchemaUnknownKeys, SuperSchemaCatchall, SuperValues, SuperDefaultValues>,
|
||||
|
||||
props: {
|
||||
schema: (props: {
|
||||
schema: Super["schema"]
|
||||
shape: Super["schema"]["shape"]
|
||||
}) => z.ZodObject<SchemaT, SchemaUnknownKeys, SchemaCatchall, Values, Values>
|
||||
|
||||
defaultValues: (defaultValues: SuperDefaultValues) => DefaultValues
|
||||
},
|
||||
) {
|
||||
|
||||
}
|
||||
},
|
||||
)
|
||||
Reference in New Issue
Block a user