Skip to content

Conversation

@asabatba
Copy link

Hi!

This commit adds code generation for functions for valibot.

Currently, functions were treated as an unsupported type. In reality, valibot has the following function-centric methods:

Which allow the user to specify expected argument and return types.

export type F = v.InferOutput<typeof F>
export const F = v.pipe(
  v.function(),
  v.args(v.tuple([v.number()])),
  v.returns(v.void())
)

Now, this feature, when used with valibot's parse or safeParse utilities, will modify the input function and add runtime type checks. This might not always be desirable, but the user can use the assert or is checks if the original data should be unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant