NPM Dependencies UPDATE
This commit is contained in:
1 parent
20c29bb4d6
commit
a9bfe7a413
599 files changed
+12369
-51423
No files matched your search
+41
@@ -0,0 +1,41 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = isDecimal;
|
||||
|
||||
var _merge = require('./util/merge');
|
||||
|
||||
var _merge2 = _interopRequireDefault(_merge);
|
||||
|
||||
var _assertString = require('./util/assertString');
|
||||
|
||||
var _assertString2 = _interopRequireDefault(_assertString);
|
||||
|
||||
var _alpha = require('./alpha');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function decimalRegExp(options) {
|
||||
var regExp = new RegExp('^[-+]?([0-9]+)?(\\' + _alpha.decimal[options.locale] + '[0-9]{' + options.decimal_digits + '})' + (options.force_decimal ? '' : '?') + '$');
|
||||
return regExp;
|
||||
}
|
||||
|
||||
var default_decimal_options = {
|
||||
force_decimal: false,
|
||||
decimal_digits: '1,',
|
||||
locale: 'en-US'
|
||||
};
|
||||
|
||||
var blacklist = ['', '-', '+'];
|
||||
|
||||
function isDecimal(str, options) {
|
||||
(0, _assertString2.default)(str);
|
||||
options = (0, _merge2.default)(options, default_decimal_options);
|
||||
if (options.locale in _alpha.decimal) {
|
||||
return !blacklist.includes(str.replace(/ /g, '')) && decimalRegExp(options).test(str);
|
||||
}
|
||||
throw new Error('Invalid locale \'' + options.locale + '\'');
|
||||
}
|
||||
module.exports = exports['default'];
|
||||
Reference in new issue
Block a user