web3-error-helper
Version:
> 🛠️ Turn confusing Web3 errors into clear, human-friendly messages for developers and users alike.
57 lines (56 loc) • 1.63 kB
TypeScript
/**
* Chain validation utilities
*
* This module provides comprehensive validation functions for chain identifiers
* and configurations across both built-in and custom chains. It focuses solely
* on validation logic without side effects, ensuring data integrity and
* providing detailed validation results for debugging and error handling.
*/
/**
* Validate if a chain identifier is valid
*
* @param chain - The chain identifier to validate
* @returns true if the chain is valid (built-in or custom)
*
* @example
* ```typescript
* if (isValidChain('ethereum')) {
* console.log('Valid chain');
* }
*
* if (isValidChain('invalid-chain')) {
* console.log('This will not execute');
* }
* ```
*/
export declare function isValidChain(chain: string): boolean;
/**
* Validate chain identifier format
*
* @param chain - The chain identifier to validate
* @returns true if the format is valid
*
* @example
* ```typescript
* isValidChainFormat('ethereum'); // true
* isValidChainFormat('my-chain'); // true
* isValidChainFormat(''); // false
* isValidChainFormat('chain with spaces'); // false
* ```
*/
export declare function isValidChainFormat(chain: string): boolean;
/**
* Get validation errors for a chain identifier
*
* @param chain - The chain identifier to validate
* @returns Array of validation error messages, empty if valid
*
* @example
* ```typescript
* const errors = getChainValidationErrors('invalid chain');
* if (errors.length > 0) {
* console.log('Validation errors:', errors);
* }
* ```
*/
export declare function getChainValidationErrors(chain: string): string[];