Validating path
Again through typeforce
This commit is contained in:
parent
182698f53d
commit
d2b43f1dfe
3 changed files with 34 additions and 5 deletions
|
@ -292,7 +292,7 @@ HDNode.prototype.isNeutered = function () {
|
|||
}
|
||||
|
||||
HDNode.prototype.derivePath = function (path) {
|
||||
typeforce(types.String, path)
|
||||
typeforce(types.Path, path)
|
||||
|
||||
var splitPath = path.split('/')
|
||||
if (splitPath[0] === 'm') {
|
||||
|
|
|
@ -26,6 +26,11 @@ function UInt53 (value) {
|
|||
Math.floor(value) === value
|
||||
}
|
||||
|
||||
function Path (value) {
|
||||
return typeforce.String(value) &&
|
||||
value.match(/^([m]\/)?([0-9]+[']?\/)*([0-9]+[']?)$/)
|
||||
}
|
||||
|
||||
// external dependent types
|
||||
var BigInt = typeforce.quacksLike('BigInteger')
|
||||
var ECPoint = typeforce.quacksLike('Point')
|
||||
|
@ -57,7 +62,8 @@ var types = {
|
|||
UInt8: UInt8,
|
||||
UInt31: UInt31,
|
||||
UInt32: UInt32,
|
||||
UInt53: UInt53
|
||||
UInt53: UInt53,
|
||||
Path: Path
|
||||
}
|
||||
|
||||
for (var typeName in typeforce) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue