Skip to content

Conversation

alexilyaev
Copy link

Resolves #1240

Reference

Mostly inspired by Zod’s implementation:

Also referenced the upcoming Valibot actions:

Open Questions

Should it be named stringbool?

  • Some of the new actions are named toSomething
  • Would be nice to keep the same name for an easier discovery and transition from Zod to Valibot

Should it accept a message?

  • What’s the criteria for deciding that?
  • Some actions accept a custom message and some don't

Do we have integration tests between a schema and an action?

  • This action should only be used with a certain schema (v.string() currently)

Copy link

vercel bot commented Jul 17, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
valibot Ready Ready Preview Comment Aug 22, 2025 6:42pm

@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. enhancement New feature or request labels Jul 17, 2025
@fabian-hiller fabian-hiller self-assigned this Jul 27, 2025
@fabian-hiller fabian-hiller requested a review from Copilot July 27, 2025 03:11
@fabian-hiller fabian-hiller added this to the v1.2 milestone Jul 27, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new stringbool action that converts string values to boolean values based on configurable truthy and falsy string lists. The implementation is inspired by Zod's string-to-boolean coercion functionality and provides case-sensitive/insensitive matching options.

  • Implements string-to-boolean transformation with customizable truthy/falsy values
  • Provides case sensitivity control with default insensitive matching
  • Includes comprehensive test coverage for all configuration options

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
library/src/actions/stringbool/stringbool.ts Core implementation of the stringbool action with options interface and transformation logic
library/src/actions/stringbool/stringbool.test.ts Comprehensive test suite covering default options, custom configurations, and error cases
library/src/actions/stringbool/stringbool.test-d.ts TypeScript type tests ensuring correct type inference for inputs, outputs, and issues
library/src/actions/stringbool/index.ts Export module for the stringbool action
library/src/actions/index.ts Adds stringbool to the main actions export
website/src/routes/api/menu.md Updates API documentation menu to include stringbool entries
website/src/routes/api/(actions)/stringbool/index.mdx API documentation for the stringbool action with usage examples
website/src/routes/api/(types)/StringboolAction/index.mdx Documentation for the StringboolAction type interface
website/src/routes/api/(types)/StringboolIssue/index.mdx Documentation for the StringboolIssue type interface
website/src/routes/api/(types)/StringboolOptions/index.mdx Documentation for the StringboolOptions type interface

Copy link

pkg-pr-new bot commented Jul 27, 2025

Open in StackBlitz

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

commit: c4b52e9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add stringbool feature similar to Zod
2 participants