JsonifiableZodSchemaClass
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
78
src/shapes/JsonifiableZodSchemaClass.ts
Normal file
78
src/shapes/JsonifiableZodSchemaClass.ts
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
import { AbstractClass, Class } from "type-fest"
|
||||||
|
import { JsonifiableObject } from "type-fest/source/jsonifiable"
|
||||||
|
import { z } from "zod"
|
||||||
|
|
||||||
|
|
||||||
|
export type JsonifiableZodSchemaClass<
|
||||||
|
Instance extends Values,
|
||||||
|
|
||||||
|
Values extends object,
|
||||||
|
JsonifiedValues extends JsonifiableObject,
|
||||||
|
|
||||||
|
JsonifySchemaT extends z.ZodRawShape,
|
||||||
|
JsonifySchemaUnknownKeys extends z.UnknownKeysParam,
|
||||||
|
JsonifySchemaCatchall extends z.ZodTypeAny,
|
||||||
|
|
||||||
|
DejsonifySchemaT extends z.ZodRawShape,
|
||||||
|
DejsonifySchemaUnknownKeys extends z.UnknownKeysParam,
|
||||||
|
DejsonifySchemaCatchall extends z.ZodTypeAny,
|
||||||
|
> = (
|
||||||
|
Class<Instance, [values: Values]> &
|
||||||
|
JsonifiableZodSchemaClassStatic<
|
||||||
|
Values,
|
||||||
|
JsonifiedValues,
|
||||||
|
|
||||||
|
JsonifySchemaT,
|
||||||
|
JsonifySchemaUnknownKeys,
|
||||||
|
JsonifySchemaCatchall,
|
||||||
|
|
||||||
|
DejsonifySchemaT,
|
||||||
|
DejsonifySchemaUnknownKeys,
|
||||||
|
DejsonifySchemaCatchall
|
||||||
|
>
|
||||||
|
)
|
||||||
|
|
||||||
|
export type JsonifiableZodSchemaAbstractClass<
|
||||||
|
Instance extends Values,
|
||||||
|
|
||||||
|
Values extends object,
|
||||||
|
JsonifiedValues extends JsonifiableObject,
|
||||||
|
|
||||||
|
JsonifySchemaT extends z.ZodRawShape,
|
||||||
|
JsonifySchemaUnknownKeys extends z.UnknownKeysParam,
|
||||||
|
JsonifySchemaCatchall extends z.ZodTypeAny,
|
||||||
|
|
||||||
|
DejsonifySchemaT extends z.ZodRawShape,
|
||||||
|
DejsonifySchemaUnknownKeys extends z.UnknownKeysParam,
|
||||||
|
DejsonifySchemaCatchall extends z.ZodTypeAny,
|
||||||
|
> = (
|
||||||
|
AbstractClass<Instance, [values: Values]> &
|
||||||
|
JsonifiableZodSchemaClassStatic<
|
||||||
|
Values,
|
||||||
|
JsonifiedValues,
|
||||||
|
|
||||||
|
JsonifySchemaT,
|
||||||
|
JsonifySchemaUnknownKeys,
|
||||||
|
JsonifySchemaCatchall,
|
||||||
|
|
||||||
|
DejsonifySchemaT,
|
||||||
|
DejsonifySchemaUnknownKeys,
|
||||||
|
DejsonifySchemaCatchall
|
||||||
|
>
|
||||||
|
)
|
||||||
|
|
||||||
|
export type JsonifiableZodSchemaClassStatic<
|
||||||
|
Values extends object,
|
||||||
|
JsonifiedValues extends JsonifiableObject,
|
||||||
|
|
||||||
|
JsonifySchemaT extends z.ZodRawShape,
|
||||||
|
JsonifySchemaUnknownKeys extends z.UnknownKeysParam,
|
||||||
|
JsonifySchemaCatchall extends z.ZodTypeAny,
|
||||||
|
|
||||||
|
DejsonifySchemaT extends z.ZodRawShape,
|
||||||
|
DejsonifySchemaUnknownKeys extends z.UnknownKeysParam,
|
||||||
|
DejsonifySchemaCatchall extends z.ZodTypeAny,
|
||||||
|
> = {
|
||||||
|
readonly jsonifySchema: z.ZodObject<JsonifySchemaT, JsonifySchemaUnknownKeys, JsonifySchemaCatchall, JsonifiedValues, Values>
|
||||||
|
readonly dejsonifySchema: z.ZodObject<DejsonifySchemaT, DejsonifySchemaUnknownKeys, DejsonifySchemaCatchall, Values, JsonifiedValues>
|
||||||
|
}
|
||||||
@@ -96,6 +96,5 @@ export const InstantiableZodSchemaObject = trait
|
|||||||
Effect.map(values => new this(values)),
|
Effect.map(values => new this(values)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
.build()
|
.build()
|
||||||
|
|||||||
Reference in New Issue
Block a user