feat(backend): add Zod validation to campaign endpoints#1190
Merged
Emmyt24 merged 1 commit intoMay 28, 2026
Merged
Conversation
Introduces src/lib/validation/campaignSchemas.ts with typed Zod schemas for every campaign endpoint: - CreateCampaignSchema (POST body) — validates Stellar address, campaign type enum, positive integer targetAmount, ISO 8601 dates with endTime > startTime, 1 KB metadata cap, and strips unknown fields via .strict() to prevent mass-assignment. - CampaignIdParamSchema (:campaignId route param) - CampaignTokenParamSchema (:tokenId route param) - CampaignCreatorParamSchema (:creator param — must be G-address) - CampaignExecutionQuerySchema (limit 1-200, non-negative offset) All invalid requests receive a structured 400 with per-field messages. Removes the previous express-validator middleware from campaigns.ts and replaces it with the new Zod-backed validateXxx helpers. Closes nova-launch01#1105 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@hman38705 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/lib/validation/campaignSchemas.tswith typed Zod schemas for every campaign endpoint.campaigns.tswith the new Zod-backed validators.400with per-field error messages..strict()on the POST body schema strips unknown fields, preventing mass-assignment.Schemas added
CreateCampaignSchema/api/campaignsbodyCampaignIdParamSchema/:campaignIdroute paramCampaignTokenParamSchema/token/:tokenIdparamCampaignCreatorParamSchema/creator/:creatorparam (G-address)CampaignExecutionQuerySchemalimit(1–200),offset(≥ 0)Validation rules (POST body)
tokenId— non-empty stringcreator— valid Stellar G-address regextype— enumBUYBACK | AIRDROP | LIQUIDITYtargetAmount— integer string > 0startTime/endTime— ISO 8601; endTime must be after startTimemetadata— optional string ≤ 1 024 chars.strict())Test plan
Closes #1105
🤖 Generated with Claude Code