valibot icon indicating copy to clipboard operation
valibot copied to clipboard

Create getMetadata/getTitle/getDescription methods

Open EskiMojo14 opened this issue 7 months ago • 4 comments

Loops through schema (including nested pipes) to shallowly merge metadata objects.

const schema = v.pipe(
  v.string(),
  v.title('title'),
  v.email(),
  v.description('description'),
  v.metadata({ key: 'value' }),
  v.pipe(v.string(), v.metadata({ extra: 'extra' }))
);
expect(v.getTitle(schema)).toBe('title')
expect(v.getDescription(schema)).toBe('description')
expect(v.getMetadata(schema)).toStrictEqual({
  key: 'value',
  extra: 'extra',
});

EskiMojo14 avatar Apr 12 '25 11:04 EskiMojo14

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
valibot ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 6, 2025 4:02am

vercel[bot] avatar Apr 12 '25 11:04 vercel[bot]

As a general feedback. I would not put the metadata method folders in a new folder /metadata folder and put them directly in the /methods folder.

fabian-hiller avatar Apr 27 '25 23:04 fabian-hiller

Open in StackBlitz

npm i https://pkg.pr.new/valibot@1154

commit: 7d1b555

pkg-pr-new[bot] avatar Apr 27 '25 23:04 pkg-pr-new[bot]

My goal is to finalize and merge this PR tomorrow or Tuesday and release these methods with Valibot v1.1 in the next few days. If it takes us longer than that, I will have to reschedule it for Valibot v1.2.

fabian-hiller avatar Apr 27 '25 23:04 fabian-hiller

Website builds locally, I have no visibility on what's upsetting Vercel 🤔

EskiMojo14 avatar Apr 30 '25 10:04 EskiMojo14

Don't worry. I will make sure everything is ok before merging. Thank you for updating the PR! I will probably merge it on the weekend and publish it with Valibot v1.1.

fabian-hiller avatar May 02 '25 03:05 fabian-hiller

I started to review this PR and will probably merge it tomorrow. Please don't modify it.

fabian-hiller avatar May 05 '25 03:05 fabian-hiller

Next, I will review the docs and merge the PR.

fabian-hiller avatar May 06 '25 03:05 fabian-hiller

Valibot v1.1.0 is available!

fabian-hiller avatar May 06 '25 04:05 fabian-hiller