Skip to content

feat: add Stellar address validation for authorAddress (#605)#626

Merged
BigBen-7 merged 2 commits into
PinSpace-Org:mainfrom
BashMan11:fix/605-stellar-address-validation
Jun 23, 2026
Merged

feat: add Stellar address validation for authorAddress (#605)#626
BigBen-7 merged 2 commits into
PinSpace-Org:mainfrom
BashMan11:fix/605-stellar-address-validation

Conversation

@BashMan11

Copy link
Copy Markdown
Contributor

Summary

Adds a custom @IsStellarAddress() class-validator decorator that validates Stellar Ed25519 public keys using the official @stellar/stellar-sdk StrKey.isValidEd25519PublicKey() method, and applies it to authorAddress in CreateGistDto.

Changes

  • Backend/src/common/validators/stellar-address.validator.ts — custom decorator
  • Backend/src/common/validators/index.ts — re-exports the decorator
  • Backend/src/gists/dto/create-gist.dto.ts — applies @IsStellarAddress() to authorAddress
  • Backend/src/common/validators/stellar-address.validator.spec.ts — unit tests

Test Results

All 5 unit tests pass:

  • ✅ passes with a valid Stellar public key
  • ✅ passes when authorAddress is absent (anonymous post)
  • ✅ fails with an invalid string → 400 with clear message
  • ✅ fails with an address not starting with G
  • ✅ fails with an empty string

Closes #605

- Create IsStellarAddress custom class-validator decorator
- Uses StrKey.isValidEd25519PublicKey() from @stellar/stellar-sdk
- Apply @IsStellarAddress() to authorAddress in CreateGistDto
- Export decorator from common/validators index
- Add unit tests covering valid, invalid, absent, and empty cases

Closes PinSpace-Org#605
@Tinna23

Tinna23 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

@BashMan11 please resolve conflicts

@BigBen-7 BigBen-7 merged commit b95b2a3 into PinSpace-Org:main Jun 23, 2026
1 check failed
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.

Add Stellar address validation middleware for authorAddress field

3 participants