Skip to content

Conversation

@patdx
Copy link

@patdx patdx commented Nov 6, 2025

Problem

The minValue and maxValue actions in @valibot/to-json-schema only supported number type, but JSON Schema supports minimum and maximum for both number and integer types. This caused an error when converting schemas that used v.pipe(v.number(), v.integer(), v.minValue()) or v.maxValue().

Error message:

The "min_value" action is not supported on type "integer".

Solution

Updated both min_value and max_value action handlers in convertAction.ts to accept both 'number' and 'integer' types, matching JSON Schema's support for these constraints.

Changes

  • Updated max_value action handler to check for both number and integer types
  • Updated min_value action handler to check for both number and integer types
  • Added test cases to cover integer type scenarios for both actions

Testing

All tests pass, including 4 new test cases:

  • convertAction > should convert min value action for integers
  • convertAction > should convert max value action for integers
  • toJsonSchema > should convert schema > for integer schema with min value
  • toJsonSchema > should convert schema > for integer schema with max value

Run pnpm test run in the packages/to-json-schema directory to verify.

@vercel
Copy link

vercel bot commented Nov 6, 2025

@patdx is attempting to deploy a commit to the Valibot Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. fix A smaller enhancement or bug fix labels Nov 6, 2025
@fabian-hiller fabian-hiller requested a review from Copilot November 6, 2025 23:50
Copy link
Contributor

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 extends the toJsonSchema converter to support minValue and maxValue actions on integer types in addition to the existing support for number types. This allows JSON schemas with integer types to properly include minimum and maximum constraints.

  • Extended type validation in convertAction to accept both 'number' and 'integer' types for min/max value actions
  • Added comprehensive test coverage for integer min/max value conversions at both unit and integration levels

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/to-json-schema/src/converters/convertAction/convertAction.ts Extended max_value and min_value action handlers to support integer types alongside number types
packages/to-json-schema/src/converters/convertAction/convertAction.test.ts Added unit tests for maxValue and minValue actions on integer schemas
packages/to-json-schema/src/functions/toJsonSchema/toJsonSchema.test.ts Added integration tests demonstrating integer schemas with min/max value constraints

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

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

Labels

fix A smaller enhancement or bug fix size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant