Skip to content

#close 129 feat: add validatePocketPayConfig helper for early SDK configuration validation#233

Merged
El-swaggerito merged 3 commits into
Axionvera:mainfrom
emmyoat:feat/validate-config-helper
Jul 23, 2026
Merged

#close 129 feat: add validatePocketPayConfig helper for early SDK configuration validation#233
El-swaggerito merged 3 commits into
Axionvera:mainfrom
emmyoat:feat/validate-config-helper

Conversation

@emmyoat

@emmyoat emmyoat commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a non-throwing configuration validation helper (validatePocketPayConfig) to allow consumers to validate SDK configuration settings early before initiating network or transaction operations.

Solution

Implemented validatePocketPayConfig which evaluates configuration options and returns a structured ConfigValidationResult containing:

  • valid: boolean (true when zero errors exist)
  • errors: Array of fatal configuration issues
  • warnings: Array of non-fatal advisory issues (e.g., insecure HTTP URLs, network/endpoint mismatches, extreme timeouts)
  • issues: Complete list of all errors and warnings
  • config: Resolved SDKConfig (populated when valid is true)

Key Changes

  • Types (src/types/index.ts): Added ConfigIssueSeverity, ConfigValidationIssue, and ConfigValidationResult.
  • Config Helper (src/config/index.ts): Added validatePocketPayConfig() and integrated sanitizeValue/redactSensitive so sensitive patterns (e.g., Stellar secret keys S...) are sanitized in validation output (S[REDACTED]).
  • Package Exports (src/index.ts): Re-exported validatePocketPayConfig and configuration validation result types from the package root.
  • Unit Tests (tests/config-validation.test.ts): Added tests covering default testnet configuration, explicit valid overrides, malformed/invalid parameters, advisory warnings, and secret key redaction.
  • Documentation (docs/configuration.md): Added an "Early Configuration Validation" guide with structured return types and TypeScript usage examples.

Usage Example

import { validatePocketPayConfig } from 'stellar-pocketpay-sdk';

const result = validatePocketPayConfig({
  network: 'testnet',
  horizonUrl: 'https://horizon-testnet.stellar.org',
  timeout: 30000,
});

if (!result.valid) {
  console.error('Configuration errors:', result.errors);
} else {
  console.log('Resolved SDK Config:', result.config);
  if (result.warnings.length > 0) {
    console.warn('Configuration warnings:', result.warnings);
  }
}

@El-swaggerito

Copy link
Copy Markdown
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.

@El-swaggerito
El-swaggerito merged commit 1baf09c into Axionvera:main Jul 23, 2026
1 check 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.

2 participants