ObservableZodSchemaObject
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:
@@ -1,14 +1,20 @@
|
||||
import { expression } from "@thilawyn/traitify-ts"
|
||||
import { InstantiableZodSchemaObject } from "./InstantiableZodSchemaObject"
|
||||
import { trait } from "@thilawyn/traitify-ts"
|
||||
import { mapValues } from "lodash-es"
|
||||
import { makeObservable, observable } from "mobx"
|
||||
import { z } from "zod"
|
||||
|
||||
|
||||
export const ObservableZodSchemaObject = expression
|
||||
.expresses(InstantiableZodSchemaObject)
|
||||
export const ObservableZodSchemaObject = trait
|
||||
.staticAbstract(Super => class extends Super {
|
||||
declare readonly schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, object, object>
|
||||
})
|
||||
.implement(Super => class ObservableZodSchemaObject extends Super {
|
||||
constructor(...args: any[]) {
|
||||
super(...args)
|
||||
|
||||
makeObservable(this,
|
||||
mapValues(ObservableZodSchemaObject.schema.shape, () => observable)
|
||||
)
|
||||
}
|
||||
})
|
||||
.build()
|
||||
.subtrait()
|
||||
.implement(Super => class ObservableZodSchemaObject extends Super {
|
||||
constructor(...args: any[]) {
|
||||
super(...args)
|
||||
}
|
||||
})
|
||||
.build()
|
||||
|
||||
Reference in New Issue
Block a user