This release is 1 version behind 0.0.49 — the latest version of @skmtc/gen-valibot. Jump to latest
@skmtc/gen-valibot@0.0.48
It is unknown whether this package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers




JSR Score
23%
Published
4 weeks ago (0.0.48)
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455import { ContentBase } from 'jsr:@skmtc/core@^0.0.974' import { toValibotValue } from './Valibot.ts' import { applyModifiers } from './applyModifiers.ts' import type { GenerateContextType, GeneratorKey, RefName, TypeSystemValue, Modifiers, OasRef, OasSchema } from 'jsr:@skmtc/core@^0.0.974' type ValibotArrayArgs = { context: GenerateContextType destinationPath: string items: OasSchema | OasRef<'schema'> modifiers: Modifiers generatorKey: GeneratorKey rootRef?: RefName } export class ValibotArray extends ContentBase { type = 'array' as const items: TypeSystemValue modifiers: Modifiers constructor({ context, generatorKey, destinationPath, items, modifiers, rootRef }: ValibotArrayArgs) { super({ context, generatorKey }) this.modifiers = modifiers this.items = toValibotValue({ destinationPath, schema: items, required: true, context, rootRef }) context.register({ imports: { valibot: [{ '*': 'v' }] }, destinationPath }) } override toString(): string { const content = `v.array(${this.items})` return applyModifiers(content, this.modifiers) } }