stargaze-studio/utils/isValidAddress.ts
2022-07-13 16:56:36 +03:00

9 lines
248 B
TypeScript

// Validates a bech32 address
export function isValidAddress(address: string): boolean {
const bech32Regex = /^[a-z]{1,83}[a-km-zA-HJ-NP-Z0-9]{39,59}$/im
if (!address.length) {
return false
}
return Boolean(bech32Regex.exec(address))
}