Skip to content

docs: fix incorrect length range in parse() error message - #300

Open
malapeiro wants to merge 1 commit into
vercel:mainfrom
malapeiro:fix-parse-length-message
Open

malapeiro wants to merge 1 commit into
vercel:mainfrom
malapeiro:fix-parse-length-message

Conversation

@malapeiro

Copy link
Copy Markdown

Summary

parse() accepts strings with length between 1 and 100, but the error
message and JSDoc state the range is "between 1 and 99". A string of
exactly 100 characters is valid input and parses successfully,
contradicting the documented contract.

Notably, PR #89 (which introduced this limit) is titled "Limit str to 100",
so the current validation reflects the original intent — the message text
is what's incorrect.

Reproduction

import { parse } from './src/index.ts';

// 100 chars — parses fine (proving the actual limit is 100)
parse('1' + '0'.repeat(97) + 'ms'); // → 1e+97

// 101 chars — throws with the misleading message
parse('1' + '0'.repeat(98) + 'ms');
// Error: Value provided to ms.parse() must be a string with length
// between 1 and 99. value="..."

Suggested fix

Update the error message and JSDoc to say "between 1 and 100" instead of
"between 1 and 99" (one line in src/index.ts).

The parse() function accepts strings of length 1 to 100, but the error
message stated 1 to 99. Aligns the message with the actual validation,
matching the intent of PR vercel#89 ("Limit str to 100").
@malapeiro
malapeiro force-pushed the fix-parse-length-message branch from afa8389 to fdb08f8 Compare September 24, 2026 22:17
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