#10895: feat(utils): add input validation utilities
stale
Cluster:
Test Coverage Enhancements
feat(utils): add input validation utilities
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
- Adds a new `src/utils/validation.ts` module providing small validation helpers (non-empty strings, length checks, regex, email, URL, enum membership, numeric ranges) with a common `ValidationResult` return type.
- Introduces unit tests in `src/utils/validation.test.ts` covering the expected success/failure cases for each validator.
- Utilities are designed to be composable via `validateAll`, including support for validators that transform input (e.g., trimming).
<h3>Confidence Score: 4/5</h3>
- Mostly safe to merge, but URL validation semantics are likely too permissive for typical usage.
- Changes are isolated to a new utility module plus tests. The main correctness concern is `validateUrl` accepting non-http(s) schemes, which can cause incorrect downstream assumptions if used for link safety/allowlisting.
- src/utils/validation.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#20496: test(utils): add comprehensive unit tests for utility functions
by masifislamm · 2026-02-19
75.8%
#12684: Test: add missing unit tests for src/utils modules
by shaynhornik · 2026-02-09
72.9%
#7346: Security: add hardening module and secure-bot extension
by AlphonseC · 2026-02-02
72.3%
#10275: feat: add multiligual support for UI
by fmyuan2000 · 2026-02-06
70.2%
#9333: Tests: add test coverage for security/audit-fs.ts
by M00N7682 · 2026-02-05
69.9%
#9273: Add files via upload
by cyrilliu1974 · 2026-02-05
69.6%
#3872: improve bash-tools.exec.ts code quality
by Bestom927 · 2026-01-29
69.2%
#13884: feat: Replace any types with proper TypeScript interfaces for bette...
by trevorgordon981 · 2026-02-11
69.2%
#4137: [AI-assisted] test(cli): add missing test cases for parseDurationMs
by sind00 · 2026-01-29
69.2%
#11979: fix: Change rootDir to project root to allow UI compilation
by fastroc · 2026-02-08
68.9%