diff --git a/src/model/model-to-valibot.ts b/src/model/model-to-valibot.ts index 1add416..256d1da 100644 --- a/src/model/model-to-valibot.ts +++ b/src/model/model-to-valibot.ts @@ -81,7 +81,15 @@ export namespace ModelToValibot { return UnsupportedType(schema) } function Function(schema: Types.TFunction) { - return UnsupportedType(schema) + const constraints: string[] = [] + if (schema.parameters !== undefined) { + const items = schema.parameters.map((schema) => Visit(schema)).join(`, `) + constraints.push(`v.args(${Type(`v.tuple`, `[${items}]`, [])})`) + } + if (schema.returns !== undefined ) { + constraints.push(`v.returns(${Visit(schema.returns)})`) + } + return Type(`v.function`, null, constraints) } function Integer(schema: Types.TInteger) { return Type(`v.number`, null, [`v.integer()`])