Commit 7bb40d1
authored
fix(validation): enforce year >= 2008 with consistent error message in zod schema (JhaSourav07#278)
## Description
Fixes JhaSourav07#146
- `lib/validations.ts` — updated the `year` field in
`streakParamsSchema` to reject any year before 2008 using a single
refine check, returning a consistent "GitHub was founded in 2008. Please
provide a year of 2008 or later." error message for all invalid year
inputs including `non-numeric`, `out-of-range`, and `pre-2008 values`.
- `app/api/streak/route.test.ts` — updated 4 test assertions to expect
the new consistent error message instead of the previous 'Invalid "year"
parameter' string.
## Pillar
- 🛠️ Other (Bug fix, refactoring, docs)
## Visual Preview
https://collection.cloudinary.com/dqvm8dce2/8a46b6e30ac67c2ca9344f3b72beb8fc
## Checklist before requesting a review:
- I have read the `CONTRIBUTING.md` file.
- I have tested these changes locally
(`localhost:3000/api/streak?user=YOUR_USERNAME&year=....`).
- I have run `npm run format` and `npm run lint` locally and resolved
all errors.
- My commits follow the Conventional Commits format.
- I have starred the repo.
- I have made sure that i have only one commit to merge in this PR.2 files changed
Lines changed: 11 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
263 | | - | |
| 263 | + | |
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | | - | |
| 271 | + | |
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
279 | | - | |
| 279 | + | |
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
289 | | - | |
| 289 | + | |
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
45 | | - | |
| 43 | + | |
46 | 44 | | |
47 | | - | |
48 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
49 | 48 | | |
50 | | - | |
51 | | - | |
| 49 | + | |
52 | 50 | | |
53 | 51 | | |
54 | | - | |
| 52 | + | |
55 | 53 | | |
56 | | - | |
57 | | - | |
| 54 | + | |
58 | 55 | | |
59 | 56 | | |
60 | 57 | | |
| |||
0 commit comments