← Back to PRs

#10895: feat(utils): add input validation utilities

by sunshine-JLU open 2026-02-07 04:36 View on GitHub →
stale
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