Merge pull request #1115 from eordano/fix/privCheck

Fix validation error
This commit is contained in:
Manuel Aráoz 2015-02-24 17:58:42 -03:00
commit 220a5bb566
2 changed files with 7 additions and 0 deletions

View File

@ -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);
};

View File

@ -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);