Skip to content

docs: add spread example to entriesFromList#1559

Open
hyunbinseo wants to merge 1 commit into
open-circle:mainfrom
hyunbinseo:docs/entries-from-list-spread
Open

docs: add spread example to entriesFromList#1559
hyunbinseo wants to merge 1 commit into
open-circle:mainfrom
hyunbinseo:docs/entries-from-list-spread

Conversation

@hyunbinseo

@hyunbinseo hyunbinseo commented Jul 21, 2026

Copy link
Copy Markdown

See https://x.com/i/status/2079192795328454926

Summary

Add an example to the entriesFromList API docs showing its result can be spread into object alongside other manually defined entries, not just passed as the sole argument.

Reasoning

Spreading entriesFromList inline avoids repeating the shared schema for every key, without needing an extra named variable either:

// no repetition, no extra variable
const SpreadEntriesFromList = v.object({
  name: v.string(),
  ...v.entriesFromList(
    ['foo', 'bar', 'baz'],
    v.pipe(v.string(), v.digits(), v.transform(Number))
  ),
});

// needs an extra declaration and a name for something only used once
const DigitsToNumber = v.pipe(v.string(), v.digits(), v.transform(Number));

const UseSharedSchema = v.object({
  name: v.string(),
  foo: DigitsToNumber,
  bar: DigitsToNumber,
  baz: DigitsToNumber,
});

Real World Example

See hyunbinseo/better-surf@9fd74e7

object(
  entriesFromList(
    RESOURCE_TYPES,
    tuple([
      pipe(
        object({
          name: string(),
          ...entriesFromList(
            ['total', 'use', 'remain'],
            pipe(string(), digits(), transform(Number))
          ),
        })
      ),
    ])
  )
);

Alternatives Considered

  • Two ### subheadings (one example per use case, like object's "Merge several objects" pattern) — dropped in favor of a single compact example, since the two snippets are just variants of the same idea rather than distinct scenarios.
  • Numbered placeholder names (ObjectSchema1/ObjectSchema2, matching the "merge several objects" convention) — replaced with ObjectSchema/ObjectSchemaWithSpread for clarity, since here both schemas are fully declared rather than referenced placeholders.

Summary by CodeRabbit

  • Documentation
    • Expanded the entriesFromList documentation with an example showing how to spread its result into an object schema.
    • Retained the existing usage example for reference.

Copilot AI review requested due to automatic review settings July 21, 2026 11:36
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. documentation Improvements or additions to documentation labels Jul 21, 2026
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4858aa40-3064-4020-8275-5a2a7818558a

📥 Commits

Reviewing files that changed from the base of the PR and between 90bc2c7 and cabad96.

📒 Files selected for processing (1)
  • website/src/routes/api/(utils)/entriesFromList/index.mdx

Walkthrough

The entriesFromList documentation now includes an ObjectSchemaWithSpread example that spreads its result into v.object({ ... }), using keyed entries composed with v.pipe(...) and v.transform(Number).

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the documentation change by mentioning the new spread example for entriesFromList.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a second example to the entriesFromList API documentation to demonstrate that the returned entries object can be spread into an object({...}) definition alongside manually defined entries, not only passed as the sole argument.

Changes:

  • Added an additional entriesFromList example using object-literal spread inside v.object({ ... }).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

@yslpn yslpn self-assigned this Jul 21, 2026
@yslpn

yslpn commented Jul 21, 2026

Copy link
Copy Markdown
Member

Thank you!

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 21, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: cabad96

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

Labels

documentation Improvements or additions to documentation lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants