Skip to content

feat: add centralized schema validation for auth APIs#105

Merged
Shriii19 merged 4 commits into
Shriii19:masterfrom
ash1shkumar:feat/schema-validation-auth
May 24, 2026
Merged

feat: add centralized schema validation for auth APIs#105
Shriii19 merged 4 commits into
Shriii19:masterfrom
ash1shkumar:feat/schema-validation-auth

Conversation

@ash1shkumar
Copy link
Copy Markdown
Contributor

Summary

This PR introduces centralized request schema validation for authentication APIs using Zod. It replaces scattered manual validation logic with reusable schema-based validation to improve security, maintainability, and consistency across auth routes.

Fixes #103


Changes Made

  • Added centralized validation schemas using Zod
  • Created reusable auth validation schema file
  • Replaced manual validation checks in signup API
  • Added schema validation for login API
  • Improved password validation rules
  • Added username regex validation
  • Improved request payload validation consistency
  • Reduced duplicated validation logic

Validation Improvements

Signup Validation

Implemented schema validation for:

  • name
  • username
  • email
  • password
  • optional fields (mobile, description, tags, due date, members)

Username Rules

  • Minimum 3 characters
  • Maximum 20 characters
  • Only letters, numbers, and underscores allowed

Password Rules

Password must contain:

  • Minimum 8 characters
  • Uppercase letter
  • Lowercase letter
  • Numeric digit

Files Modified

  • frontend/app/api/auth/signup/route.ts
  • frontend/app/api/auth/login/route.ts
  • frontend/lib/validations/auth.ts
  • package.json
  • package-lock.json

Tech Stack / Libraries

  • Added zod for schema-based validation

Benefits

  • Centralized validation architecture
  • Improved API security
  • Better maintainability
  • Reusable validation schemas
  • Cleaner auth route logic
  • Improved input sanitization and consistency

Type of Change

  • Security Enhancement
  • Backend Improvement
  • Validation Refactor
  • Architecture Improvement

Program

Contributing under:

  • GSSoC 2026
  • NSoC 2026

@vercel
Copy link
Copy Markdown

vercel Bot commented May 24, 2026

@ash1shkumar is attempting to deploy a commit to the shreemp194-gmailcom's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown

👋 Thank you for opening this pull request! I will review your changes and assist you soon.

@ash1shkumar
Copy link
Copy Markdown
Contributor Author

Hi @Shriii19 👋 This PR is ready for review. Kindly review it and add appropriate gssoc, nsoc, and respective level/difficulty labels as I am contributing under GSSoC and NSoC . Thank you!

@vercel
Copy link
Copy Markdown

vercel Bot commented May 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
flow-forge Ready Ready Preview, Comment May 24, 2026 5:37pm

@Shriii19
Copy link
Copy Markdown
Owner

20:01:47.844 Running build in Washington, D.C., USA (East) – iad1
20:01:47.845 Build machine configuration: 2 cores, 8 GB
20:01:47.998 Cloning github.com/Shriii19/FlowForge (Branch: feat/schema-validation-auth, Commit: ebf9eff)
20:01:48.894 Cloning completed: 894.000ms
20:01:49.049 Found .vercelignore
20:01:49.053 Removed 0 ignored files defined in .vercelignore
20:01:49.504 Restored build cache from previous deployment (GCwRSxQyBduxhBzjX9b1G61M9X43)
20:01:49.763 Running "vercel build"
20:01:49.786 Vercel CLI 54.4.1
20:01:50.187 Running "install" command: npm install --no-workspaces...
20:01:58.823
20:01:58.824 up to date, audited 436 packages in 8s
20:01:58.825
20:01:58.825 146 packages are looking for funding
20:01:58.826 run npm fund for details
20:01:58.864
20:01:58.865 5 moderate severity vulnerabilities
20:01:58.865
20:01:58.866 To address issues that do not require attention, run:
20:01:58.866 npm audit fix
20:01:58.867
20:01:58.867 To address all issues (including breaking changes), run:
20:01:58.868 npm audit fix --force
20:01:58.869
20:01:58.869 Run npm audit for details.
20:01:58.916 Detected Next.js version: 16.2.6
20:01:58.917 Running "npm run build"
20:01:59.044 npm warn config ignoring workspace config at /vercel/path0/frontend/.npmrc
20:01:59.073
20:01:59.073 > frontend@0.1.0 build
20:01:59.074 > cross-env NODE_OPTIONS=--max-old-space-size=4096 next build
20:01:59.074
20:02:00.013 Applying modifyConfig from Vercel
20:02:00.030 ▲ Next.js 16.2.6 (Turbopack)
20:02:00.031
20:02:00.073 Creating an optimized production build ...
20:02:16.107
20:02:16.108 > Build error occurred
20:02:16.115 Error: Turbopack build failed with 1 errors:
20:02:16.115 ./frontend/app/api/auth/signup/route.ts:5:1
20:02:16.116 Module not found: Can't resolve '@/lib/validations/auth'
20:02:16.116 3 | import { NextRequest, NextResponse } from "next/server";
20:02:16.116 4 | import { randomUUID } from "crypto";
20:02:16.116 > 5 | import { signupSchema } from "@/lib/validations/auth";
20:02:16.117 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20:02:16.117 6 |
20:02:16.117 7 |
20:02:16.117 8 | export const runtime = "nodejs";
20:02:16.118
20:02:16.118 Import map: aliased to relative './lib/validations/auth' inside of [project]/frontend
20:02:16.118
20:02:16.118
20:02:16.118 https://nextjs.org/docs/messages/module-not-found
20:02:16.119
20:02:16.119
20:02:16.119 at (./frontend/app/api/auth/signup/route.ts:5:1)
20:02:16.119 at (https://nextjs.org/docs/messages/module-not-found)
20:02:16.189 npm error Lifecycle script build failed with error:
20:02:16.190 npm error code 1
20:02:16.190 npm error path /vercel/path0/frontend
20:02:16.191 npm error workspace frontend@0.1.0
20:02:16.191 npm error location /vercel/path0/frontend
20:02:16.191 npm error command failed
20:02:16.192 npm error command sh -c cross-env NODE_OPTIONS=--max-old-space-size=4096 next build
20:02:16.213 Error: Command "npm run build" exited with 1

@Shriii19
Copy link
Copy Markdown
Owner

@ash1shkumar can you fix those building error.

@ash1shkumar
Copy link
Copy Markdown
Contributor Author

@Shriii19 , The previous Vercel build issues and merge conflicts have been resolved. The schema validation import path was corrected, conflicts were cleaned up, and the project should now build successfully. Kindly recheck the PR when possible. Thank you!

@Shriii19 Shriii19 merged commit 84131de into Shriii19:master May 24, 2026
6 checks passed
@ash1shkumar ash1shkumar deleted the feat/schema-validation-auth branch May 25, 2026 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[NSOC] Missing Request Schema Validation

2 participants