feat: cap message field at 2000 chars with validation and tests (Closes #1504) - #1618
Open
waterWang wants to merge 1 commit into
Open
feat: cap message field at 2000 chars with validation and tests (Closes #1504)#1618waterWang wants to merge 1 commit into
waterWang wants to merge 1 commit into
Conversation
Adds server-side validation for the optional message field used in remittance and emergency-transfer flows. The message is capped at 2000 characters to prevent abuse and ensure database consistency. - Add validateMessage() utility function in utils/validation.ts - Wire validation into both remittance build API routes - Add INVALID_MESSAGE error code to EmergencyTransferErrorCode - Add typed message field to EmergencyTransferRequest interface - Add comprehensive unit tests covering happy path, edge cases, and multi-byte/emoji input Closes Remitwise-Org#1504
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
Adds server-side validation for the optional message field used in remittance and emergency-transfer flows. The message is capped at 2000 characters to prevent abuse and ensure database consistency.
Changes
utils/validation.ts: AddedvalidateMessage()function that checks character length (not byte length, since this is a user-facing message, not a Stellar memo)app/api/remittance/build/route.ts: Wire message validation into the remittance build endpointapp/api/v1/remittance/emergency/build/route.ts: Wire message validation into the emergency transfer build endpointtypes/emergency-transfer.ts: AddedINVALID_MESSAGEerror code and optionalmessagefield toEmergencyTransferRequesttests/unit/remittance/build-validation.test.ts: Added comprehensive unit tests forvalidateMessage()covering:Implementation Details
EmergencyTransferErrorCode.INVALID_MESSAGE), never stringly-typed 400validateMemo()andvalidateAmount()functionsCloses #1504