Standard libraries that lift up your code.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
851 B

import { z } from 'zod'
import {Container, Singleton} from '../di'
import {Collection, Maybe} from '../util'
type ZodifyRegistrant = { id: number, schema: z.ZodType<any> }
export function registerZodifiedSchema<T>(id: number, schema: z.ZodType<T>): z.ZodType<T> {
.register(id, schema)
return schema
export class ZodifyRegistrar {
protected registeredSchemata: Collection<ZodifyRegistrant> = new Collection<ZodifyRegistrant>()
public register(id: number, schema: z.ZodType<any>): this {
return this
public get(id: number): Maybe<z.ZodType<any>> {
return this.registeredSchemata.firstWhere('id', '=', id)?.schema