Skip to content

feat: add centralized snippet request validation - #177

Merged
SudiptaPaul-31 merged 4 commits into
SudiptaPaul-31:mainfrom
Okorie2000-code:feat/157-snippet-request-validation
Sep 1, 2026
Merged

feat: add centralized snippet request validation#177
SudiptaPaul-31 merged 4 commits into
SudiptaPaul-31:mainfrom
Okorie2000-code:feat/157-snippet-request-validation

Conversation

@Okorie2000-code

Copy link
Copy Markdown
Contributor

Introduce a single validation module reused by every snippet operation (create, update, import, share): title 3-100 chars, supported-language enum, code size/whitespace limits, Stellar wallet format+checksum via the SDK, and visibility restricted to private/public/shared. All failures return one consistent JSON error payload with HTTP 400 and nothing is persisted for invalid input. Adds a bounded ZIP reader plus an import endpoint that validates JSON/ZIP manifests before persistence and always assigns the authenticated wallet as owner. Includes a visibility column migration and comprehensive unit/route tests.

Closes #157

Introduce a single validation module reused by every snippet operation
(create, update, import, share): title 3-100 chars, supported-language
enum, code size/whitespace limits, Stellar wallet format+checksum via
the SDK, and visibility restricted to private/public/shared. All
failures return one consistent JSON error payload with HTTP 400 and
nothing is persisted for invalid input. Adds a bounded ZIP reader plus
an import endpoint that validates JSON/ZIP manifests before persistence
and always assigns the authenticated wallet as owner. Includes a
visibility column migration and comprehensive unit/route tests.

Closes SudiptaPaul-31#157

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@SudiptaPaul-31

Copy link
Copy Markdown
Owner

@Okorie2000-code resolve conflicts

… regenerate lockfile

- createSnippetSchema now uses walletAddressSchema (Stellar StrKey checksum
  validation) and languageSchema (enum allowlist) so invalid wallet addresses
  and unsupported languages are rejected with a ZodError before any DB call
- Added optional visibility field to createSnippetSchema using visibilitySchema
- Regenerated package-lock.json to match current package.json and resolve
  lockfile conflict with main
- lib/snippet.service.test.ts: merged upstream's IPFSService import and our
  ZodError import; updated duplicate/fork tests to match new repository-
  delegated service API; kept all Zod validation tests (wallet, language,
  visibility)
- package.json: merged devDependencies, removed duplicate keys introduced by
  the conflict, added undici and eslint/typescript-eslint from upstream
- package-lock.json: regenerated cleanly from merged package.json

All 19 tests in lib/snippet.service.test.ts pass.
@Okorie2000-code

Copy link
Copy Markdown
Contributor Author

@Okorie2000-code resolve conflicts

done sir.

Am really sorry for the delay.....due to some issues...

thanks sir.

@SudiptaPaul-31
SudiptaPaul-31 merged commit 217335e into SudiptaPaul-31:main Sep 1, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API Request Validation Layer

2 participants