UNPKG

@fordefi-public/crypto-address-validator-ts

Version:

Crypto address validator for Bitcoin and other Altcoins, forked to be used with typescript

23 lines (16 loc) 666 B
import { getAll, getByNameOrSymbol } from './currencies'; import { Options } from './types/types'; export function validate(address: string, currencyNameOrSymbol: string, opts: Options | null) { var currency = getByNameOrSymbol(currencyNameOrSymbol); if (currency && currency.validator) { return currency.validator(address, currency, opts); } throw new Error('Missing validator for currency: ' + currencyNameOrSymbol); } export function getCurrencies() { return getAll(); } export function findCurrency(symbol: string) { return getByNameOrSymbol(symbol) || null ; } export default { validate, getCurrencies, findCurrency };