Browse Source

Fix validation error

patch-2
eordano 10 years ago
parent
commit
9409698e06
  1. 3
      lib/privatekey.js
  2. 4
      test/privatekey.js

3
lib/privatekey.js

@ -302,6 +302,9 @@ PrivateKey.getValidationError = function(data, network) {
* @returns {Boolean} If the private key is would be valid
*/
PrivateKey.isValid = function(data, network){
if (!data) {
return false;
}
return !PrivateKey.getValidationError(data, network);
};

4
test/privatekey.js

@ -267,6 +267,10 @@ describe('PrivateKey', function() {
a.should.equal(false);
});
it('should recognize that undefined is an invalid private key', function() {
PrivateKey.isValid().should.equal(false);
});
it('should validate as true', function() {
var a = PrivateKey.isValid('L3T1s1TYP9oyhHpXgkyLoJFGniEgkv2Jhi138d7R2yJ9F4QdDU2m');
a.should.equal(true);

Loading…
Cancel
Save