fcoin/lib/wallet/common.js
2016-11-19 05:29:29 -08:00

27 lines
522 B
JavaScript

/*!
* common.js - commonly required functions for wallet.
* Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
var common = exports;
/**
* Test whether a string is eligible
* to be used as a name or ID.
* @param {String} key
* @returns {Boolean}
*/
common.isName = function isName(key) {
if (typeof key !== 'string')
return false;
if (!/^[\-\._0-9A-Za-z]+$/.test(key))
return false;
return key.length >= 1 && key.length <= 40;
};