Skip to content

fix(core): support numeric strings in min and max validation - #318

Open
ken8203 wants to merge 1 commit into
vercel-labs:mainfrom
ken8203:codex/fix-core-numeric-range-validation
Open

fix(core): support numeric strings in min and max validation#318
ken8203 wants to merge 1 commit into
vercel-labs:mainfrom
ken8203:codex/fix-core-numeric-range-validation

Conversation

@ken8203

@ken8203 ken8203 commented Aug 13, 2026

Copy link
Copy Markdown

Summary

  • Allow the built-in min and max validators to evaluate finite numeric strings.
  • Continue rejecting empty strings, whitespace, non-numeric strings, booleans, NaN, and Infinity.
  • Document the updated range validation behavior.

Motivation

HTML inputs store their values as strings, including <input type="number">. The shadcn renderer therefore writes values such as "12" to state.

The built-in min and max validators currently accept only JavaScript numbers, so a valid number input can fail both range checks:

builtInValidationFunctions.min("12", { min: 0 }); // false
builtInValidationFunctions.max("12", { max: 120 }); // false

This change safely converts non-empty numeric strings before comparison while avoiding broad JavaScript coercion for values such as "", false, or null.

Related but non-overlapping: #306 tightens the standalone numeric validator. This PR only addresses range validation for input values.

Testing

  • vitest run packages/core/src/validation.test.ts --environment node --maxWorkers 1 — 103 tests passed
  • pnpm --filter @json-render/core build
  • Prettier check for the changed TypeScript files

@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

@ken8203 is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@ken8203
ken8203 marked this pull request as ready for review August 13, 2026 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant