Skip to content

Feature Request: Auto-infer initialInput defaults from Schema (Single Source of Truth) #53

@Mado13

Description

@Mado13

If we are trying to implement the schema as the single source of truth, and we are building the form in the Valibot schema, why are we breaking the contract by initializing the form with undefined as default values?

If my schema states name: v.optional(v.string()) — then yes, initialInput for name should be undefined.

But if my schema states name: v.string() — then the initialInput should be "".

Currently, this forces the developer to manually create an initialInput object, which is just copying their schema into a JavaScript object.

I think inferring the initialInput object from the schema will improve DX and push towards a true single source of truth.

I can work on a PR but I just want to know if there is a compelling reason why Formisch chose to go that way?

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestpriorityThis has priority

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions