mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 12:15:51 +00:00
committed by
Mayukha Vadari
parent
f5dee87ca7
commit
edcdd3a0fc
@@ -56,6 +56,17 @@ function isValidSecret(secret: string): boolean {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that a given address is a valid X-Address or a valid classic
|
||||
* address.
|
||||
*
|
||||
* @param address - Address to validate.
|
||||
* @returns True if address is a valid X-Address or classic address.
|
||||
*/
|
||||
function isValidAddress(address: string): boolean {
|
||||
return isValidXAddress(address) || isValidClassicAddress(address)
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes undefined values from an object.
|
||||
*
|
||||
@@ -94,6 +105,7 @@ export {
|
||||
rippleTimeToUnixTime,
|
||||
unixTimeToRippleTime,
|
||||
isValidSecret,
|
||||
isValidAddress,
|
||||
computeSignedTransactionHash,
|
||||
computeBinaryTransactionSigningHash,
|
||||
computeAccountRootIndex,
|
||||
|
||||
25
test/utils/isValidAddress.ts
Normal file
25
test/utils/isValidAddress.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { isValidAddress } from 'xrpl-local'
|
||||
|
||||
describe('isValidAddress', function () {
|
||||
it('Validates valid classic address', function () {
|
||||
const classic = 'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W'
|
||||
assert(isValidAddress(classic))
|
||||
})
|
||||
|
||||
it('Does not validate invalid classic address', function () {
|
||||
const classic = 'r3rhWeE31Jt5sWmi4QiGLMZnY3ENhqw96W'
|
||||
assert(!isValidAddress(classic))
|
||||
})
|
||||
|
||||
it('Validates valid X-Address', function () {
|
||||
const xAddress = 'XV5sbjUmgPpvXv4ixFWZ5ptAYZ6PD28Sq49uo34VyjnmK5H'
|
||||
assert(isValidAddress(xAddress))
|
||||
})
|
||||
|
||||
it('Does not validate invalid X-Address', function () {
|
||||
const xAddress = 'XV5sbjUmgPpvXv4ixFWZ5pfAYZ6PD28Sq49uo34VyjnmK5H'
|
||||
assert(!isValidAddress(xAddress))
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user