feat(payments): add validateSendXLMParams non-throwing helper (closes #87)#228
Merged
El-swaggerito merged 1 commit intoJul 23, 2026
Merged
Conversation
Contributor
|
This PR cannot be merged automatically because it has merge conflicts. Please update the branch with the latest base branch and resolve the conflicts. After the conflicts are resolved and checks pass, the automation can review it again. |
…xionvera#87) Adds validateSendXLMParams(params), a pure input-validation companion to sendXLM. Runs the same preflight checks (secret key, destination public key, amount format + positivity + 7-decimal precision, memo byte length, self-payment detection) and returns a discriminated { ok } result rather than throwing on the first failure. Consumers can enumerate every field error at once to drive form UIs. Never touches the network. Tests: 14 new cases in tests/payments-validation.test.ts covering the happy path, each field-level failure, multi-error collection, the skip-self-payment-when-secret-invalid guard, multi-byte memo boundaries, and total-function behavior on runtime junk input. Docs: getting-started.md gets a "Validating input before sending" block next to the sendXLM section; api-reference.md gains a short function reference with the ValidationError type.
Labi-Joy
force-pushed
the
feat/87-validate-send-xlm-params
branch
from
July 23, 2026 10:54
05e26fe to
9d67075
Compare
7 tasks
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.
Closes #87.
Summary
Adds
validateSendXLMParams(params), a pure non-throwing input-validation companion tosendXLM. Runs the same preflight checkssendXLMperforms internally (secret key format, destination public key format, amount format + positivity + 7-decimal precision, memo byte length, self-payment detection) and returns a discriminated{ ok: true } | { ok: false; errors: ValidationError[] }result. Callers can enumerate every field error at once to drive form UIs instead of catching thrown errors one at a time. Never touches the network.Tests
npx vitest run tests/payments-validation.test.ts— 14 pass, 0 fail:SELF_PAYMENTalongside a realINVALID_SECRET_KEY)Docs
docs/getting-started.mdgets a "Validating input before sending" block next to the sendXLM section.docs/api-reference.mdgains a short function reference with theValidationErrortype shape.Notes for the reviewer
sendXLMandvalidateSendXLMParamscall the same underlyingvalidateSecretKey,validatePublicKey,validateAmount,validateMemoutilities, so the "reuse the same validation logic" acceptance criterion is met without changing the existing throwing path. That keeps this PR small and low-risk for existing consumers.err.code, not onerr.message. Codes are part of the SDK's public contract; messages are not.main:tsc --noEmitstill reports 8 errors insrc/transactions/fixtures.tsfrom the recently-merged fixtures PR (TransactionDirectionused as a value instead of a type, andidonTransactionSummary). Not touched by this PR, worth a follow-up.