Use one constant for the 10,000-character input limit

Open Beginner friendly
#51 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@NginxL is already working on this.

Since Dec 5, 2026.

  • #52 by @NginxL — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript
Domain
backend, testing

Research direction

Read src/utils/safeRegex.js and src/core/BaseValidator.js around patternAsync(). Export the existing MAX_INPUT_LENGTH for internal use and reference it in patternAsync() without adding it to src/index.js. Add coverage for the too-long input and unsafe-regex rejection paths, then run npm run test:coverage; done when no 10000 remains in BaseValidator.js and safeRegex.js reaches 100% line coverage.

Written by the indexing model from the issue text.

Description

good first issue refactor

src/utils/safeRegex.js defines MAX_INPUT_LENGTH = 10000, but patternAsync() in src/core/BaseValidator.js (around line 440) hard-codes 10000 again. If one changes, the other won't.

Suggested fix

  • Export MAX_INPUT_LENGTH from src/utils/safeRegex.js and use it in patternAsync()
  • While you're there, add tests for the lines coverage reports as untested in safeRegex.js (the reject paths in safeRegexTest: input too long, and an unsafe regex)

Done when

  • No literal 10000 left in src/core/BaseValidator.js
  • npm run test:coverage shows safeRegex.js at 100% lines
  • Don't add the constant to the public exports in src/index.js (that would be an API change)
Dominant language
JavaScript
Stars
0
Forks
7
Avg merge
1h 17m
Merged PRs (30d)
6

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aniru-dh21/snap-validate

All issues in aniru-dh21/snap-validate

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.