Skip to content

[P3] Reject zero and negative amounts in DonatePoolDto #1141

Description

@cyber-punk112

Description

src/pools/dto/donate-pool.dto.ts's amount field only has @IsNumberString() and @IsNotEmpty(). class-validator's IsNumberString accepts negative numbers and "0" by default, so POST /pools/:id/donate with { "amount": "-100" } or { "amount": "0" } currently passes validation and reaches ContractService.buildDonateTransaction, which will build a nonsensical unsigned transaction for the caller to sign.

Deliverables

  • Add a custom validator (or @Matches(/^[1-9][0-9]*$/)) to DonatePoolDto.amount that rejects zero, negative, and non-integer values
  • Add tests confirming amount: "0" and amount: "-5" are rejected with 400
  • npm run build passes

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

    MediumbackendNestJS server workgood first issueGood for newcomersphase-2Phase 2 beginner-friendly backlog: cleanup, tests, docs, polish

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions