Skip to content

[Backend] Add a global ValidationPipe in main.ts #134

Description

@Muhammadcodes112

Description

Without this, DTO validation decorators (class-validator) on request bodies/queries do nothing — this one line is what makes them actually enforce.

Where

astre_server/src/main.ts

What to implement

app.useGlobalPipes(new ValidationPipe({ whitelist: true, forbidNonWhitelisted: true, transform: true }));

added before app.listen(...).

Acceptance Criteria

  • The pipe is registered globally in main.ts
  • A request with an invalid field (per any DTO's class-validator decorators, e.g. GET /pools?status=NotARealStatus) now returns 400 instead of passing through unvalidated
  • npm run build compiles cleanly

Hints

  • This is a one-line change but unblocks the acceptance criteria of several other issues (like "Implement PoolsController GET /pools"'s 400-on-invalid-status requirement) — worth doing early.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendNestJS API (astre_server)good first issueGood for newcomersphase-1Core donation-loop MVP (1/3 scope), builds on mvp-phase-1 branch

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions