mirror of https://codeberg.org/pzp/pzp-db.git
Add returns to validation
This commit is contained in:
parent
0084f54600
commit
b9dc3778a5
|
@ -55,6 +55,7 @@ function validateShape(msg) {
|
|||
if (typeof msg.sig !== 'string') {
|
||||
return 'invalid msg: must have sig\n' + JSON.stringify(msg)
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,6 +78,7 @@ function validateSigkey(msg) {
|
|||
// prettier-ignore
|
||||
return `invalid msg: sigkey "${sigkey}" should have been a base58 string\n` + JSON.stringify(msg)
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -106,6 +108,7 @@ function validateSigkeyAndAccount(msg, tangle, sigkeys) {
|
|||
return `invalid msg: accountTips "${msg.metadata.accountTips}" should have been null in an account tangle\n` + JSON.stringify(msg)
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -122,6 +125,7 @@ function validateMsgID(str) {
|
|||
} catch (err) {
|
||||
return `invalid msgID "${str}": should have been a base58 string`
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -158,6 +162,7 @@ function validateSignature(msg) {
|
|||
if (!verified) {
|
||||
return 'invalid msg: sig is invalid\n' + JSON.stringify(msg)
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -241,6 +246,7 @@ function validateTangle(msg, tangle, tangleID) {
|
|||
// prettier-ignore
|
||||
return `invalid msg: depth must be the largest prev depth plus one\n` + JSON.stringify(msg)
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -257,6 +263,7 @@ function validateTangleRoot(msg, msgID, tangleID) {
|
|||
// prettier-ignore
|
||||
return `invalid msg: tangle root "${tangleID}" must not have self tangle data\n` + JSON.stringify(msg)
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -277,6 +284,7 @@ function validateDomain(domain) {
|
|||
// prettier-ignore
|
||||
return `invalid domain: "${domain}" contains characters other than a-z, A-Z, 0-9, or _`
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -295,6 +303,7 @@ function validateData(msg) {
|
|||
// prettier-ignore
|
||||
return `invalid msg: data "${data}" must be an object or a string` + JSON.stringify(msg)
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -317,6 +326,7 @@ function validateDataSizeHash(msg) {
|
|||
// prettier-ignore
|
||||
return `invalid msg: metadata.dataSize ${actualSize} should have been "${expectedSize}"\n` + JSON.stringify(msg)
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue