ZodSchemaClassOf refactoring
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:
35
src/tests.ts
35
src/tests.ts
@@ -1,28 +1,19 @@
|
||||
import { expression } from "@thilawyn/traitify-ts"
|
||||
import { AbstractClass } from "type-fest"
|
||||
import { Implements } from "@thilawyn/traitify-ts"
|
||||
import { z } from "zod"
|
||||
import { ZodSchemaClass } from "./ZodSchemaClass"
|
||||
import { ExtendableZodSchemaObject } from "./lib"
|
||||
import { InstantiableZodSchemaObject } from "./traits/InstantiableZodSchemaObject"
|
||||
|
||||
|
||||
class Test extends ZodSchemaClass({
|
||||
const TestExp = ZodSchemaClass({
|
||||
schema: z.object({
|
||||
id: z.bigint(),
|
||||
name: z.string(),
|
||||
}),
|
||||
|
||||
defaultValues: { id: -1n },
|
||||
}) {}
|
||||
}).build()
|
||||
|
||||
const Test2 = ZodSchemaClass({
|
||||
schema: z.object({
|
||||
id: z.bigint(),
|
||||
name: z.string(),
|
||||
}),
|
||||
|
||||
defaultValues: { id: -1n },
|
||||
})
|
||||
@TestExp.implementsStatic
|
||||
class Test extends TestExp.extends implements Implements<typeof TestExp> {}
|
||||
|
||||
Test.defaultValues
|
||||
const inst = Test.create({ id: 1n, name: "" })
|
||||
@@ -45,19 +36,3 @@ console.log(subInst)
|
||||
// class ChildTest extends Test {}
|
||||
|
||||
// ChildTest.instantiate({ name: "" })
|
||||
|
||||
|
||||
class Gneugneu {
|
||||
|
||||
}
|
||||
|
||||
export function getExpression<C extends AbstractClass<object>>(class_: C) {
|
||||
return expression
|
||||
.extends(class_)
|
||||
.expresses(
|
||||
InstantiableZodSchemaObject,
|
||||
ExtendableZodSchemaObject,
|
||||
)
|
||||
}
|
||||
|
||||
const exp = getExpression(Gneugneu).build()
|
||||
|
||||
Reference in New Issue
Block a user