fabian-hiller / valibot

The modular and type safe schema library for validating structural data 🤖
https://valibot.dev
MIT License
6.33k stars 204 forks source link

Add "dependent default" example to `v.optional` #877

Closed fartinmartin closed 3 weeks ago

fartinmartin commented 1 month ago

As I understand, this is the conventional way to apply default values to optional props. I thought we could include it in the docs (until if/when a more concise API is added)!

fabian-hiller commented 1 month ago

I think the API reference of optional is probably the wrong location but we could add such an example to the optionals guide: https://valibot.dev/guides/optionals/

fartinmartin commented 1 month ago

Ah, totally—that makes sense to me! I've updated the branch, let me know if I should tweak it further!

fabian-hiller commented 1 month ago

Thank you! I will try to review it on the weekend.

pkg-pr-new[bot] commented 3 weeks ago

Open in Stackblitz

pnpm add https://pkg.pr.new/valibot@877

commit: be49b89