haw-utils
Version:
一个基于业务场景的工具方法库
48 lines (46 loc) • 1.17 kB
JavaScript
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["exports"], factory);
} else if (typeof exports !== "undefined") {
factory(exports);
} else {
var mod = {
exports: {}
};
factory(mod.exports);
global.isBankCard = mod.exports;
}
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports["default"] = void 0;
// 银行卡号正则 非0开头,15至19位数字
var reg = /^[1-9]\d{14,18}$/;
/**
* 检测值是否为银行卡号
*
* @static
* @alias module:Validator.isBankCard
* @since 1.1.0
* @param {String} value 要检测的值
* @returns {Boolean} 值是否为银行卡号
* @example
*
* isBankCard('6228480402564890018');
* // => true
*
* isBankCard('6228480402564890');
* // => true
*
* isBankCard('123456789');
* // => false
*
*/
function isBankCard(value) {
return reg.test(value);
}
var _default = isBankCard;
_exports["default"] = _default;
});