Repository navigation
fix(core): reject partial and empty numeric strings - #389
Merged
Merged
Conversation
parseFloat accepted "123abc" as 123, and Number() alone treats "" and whitespace as 0. Require a non-empty string that Number() parses fully. Co-Authored-By: vitalii.semianchuk <fix20152@gmail.com>
Contributor
ctate
self-requested a review
October 8, 2026 12:31
ctate
approved these changes
Oct 12, 2026
Merged
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
numericvalidator usedparseFloat, so"123abc"and"99bottles"passed as valid numbers. Switching toNumber()alone would let""and whitespace-only strings pass, since both coerce to 0. The validator now requires a non-empty string thatNumber()parses fully, with tests for both cases.Recreates the numeric half of #306 by @fix2015, credited as co-author. The
$truncatehalf changes documented behavior (existing tests expect the suffix afterlength), so it is left out of this PR.