PATH:
usr
/
local
/
lib
/
node_modules
/
ghost-cli
/
node_modules
/
validator
/
lib
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = isCurrency; var _merge = require('./util/merge'); var _merge2 = _interopRequireDefault(_merge); var _assertString = require('./util/assertString'); var _assertString2 = _interopRequireDefault(_assertString); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function currencyRegex(options) { var symbol = '(\\' + options.symbol.replace(/\./g, '\\.') + ')' + (options.require_symbol ? '' : '?'), negative = '-?', whole_dollar_amount_without_sep = '[1-9]\\d*', whole_dollar_amount_with_sep = '[1-9]\\d{0,2}(\\' + options.thousands_separator + '\\d{3})*', valid_whole_dollar_amounts = ['0', whole_dollar_amount_without_sep, whole_dollar_amount_with_sep], whole_dollar_amount = '(' + valid_whole_dollar_amounts.join('|') + ')?', decimal_amount = '(\\' + options.decimal_separator + '\\d{2})?'; var pattern = whole_dollar_amount + decimal_amount; // default is negative sign before symbol, but there are two other options (besides parens) if (options.allow_negatives && !options.parens_for_negatives) { if (options.negative_sign_after_digits) { pattern += negative; } else if (options.negative_sign_before_digits) { pattern = negative + pattern; } } // South African Rand, for example, uses R 123 (space) and R-123 (no space) if (options.allow_negative_sign_placeholder) { pattern = '( (?!\\-))?' + pattern; } else if (options.allow_space_after_symbol) { pattern = ' ?' + pattern; } else if (options.allow_space_after_digits) { pattern += '( (?!$))?'; } if (options.symbol_after_digits) { pattern += symbol; } else { pattern = symbol + pattern; } if (options.allow_negatives) { if (options.parens_for_negatives) { pattern = '(\\(' + pattern + '\\)|' + pattern + ')'; } else if (!(options.negative_sign_before_digits || options.negative_sign_after_digits)) { pattern = negative + pattern; } } // ensure there's a dollar and/or decimal amount, and that // it doesn't start with a space or a negative sign followed by a space return new RegExp('^(?!-? )(?=.*\\d)' + pattern + '$'); } var default_currency_options = { symbol: '$', require_symbol: false, allow_space_after_symbol: false, symbol_after_digits: false, allow_negatives: true, parens_for_negatives: false, negative_sign_before_digits: false, negative_sign_after_digits: false, allow_negative_sign_placeholder: false, thousands_separator: ',', decimal_separator: '.', allow_space_after_digits: false }; function isCurrency(str, options) { (0, _assertString2.default)(str); options = (0, _merge2.default)(options, default_currency_options); return currencyRegex(options).test(str); } module.exports = exports['default'];
[-] isBoolean.js
[edit]
[-] isHexColor.js
[edit]
[-] equals.js
[edit]
[-] isUppercase.js
[edit]
[-] toInt.js
[edit]
[-] toDate.js
[edit]
[-] isIn.js
[edit]
[-] isDivisibleBy.js
[edit]
[-] toBoolean.js
[edit]
[-] isHexadecimal.js
[edit]
[+]
..
[-] isMobilePhone.js
[edit]
[-] isMD5.js
[edit]
[-] stripLow.js
[edit]
[-] contains.js
[edit]
[-] blacklist.js
[edit]
[-] isJSON.js
[edit]
[-] isURL.js
[edit]
[-] toFloat.js
[edit]
[-] isNumeric.js
[edit]
[-] isVariableWidth.js
[edit]
[-] isUUID.js
[edit]
[-] isDate.js
[edit]
[-] unescape.js
[edit]
[-] isISRC.js
[edit]
[-] isInt.js
[edit]
[-] alpha.js
[edit]
[-] isISSN.js
[edit]
[-] rtrim.js
[edit]
[-] isSurrogatePair.js
[edit]
[-] isMongoId.js
[edit]
[-] isCreditCard.js
[edit]
[-] isFullWidth.js
[edit]
[-] isISO8601.js
[edit]
[-] isBase64.js
[edit]
[-] isHalfWidth.js
[edit]
[-] isByteLength.js
[edit]
[-] isDataURI.js
[edit]
[-] isAfter.js
[edit]
[-] isISIN.js
[edit]
[-] normalizeEmail.js
[edit]
[-] isAlpha.js
[edit]
[-] isBefore.js
[edit]
[+]
util
[-] isCurrency.js
[edit]
[-] isWhitelisted.js
[edit]
[-] isMACAddress.js
[edit]
[-] ltrim.js
[edit]
[-] isLength.js
[edit]
[-] whitelist.js
[edit]
[-] isDecimal.js
[edit]
[-] isMultibyte.js
[edit]
[-] matches.js
[edit]
[-] trim.js
[edit]
[-] isAlphanumeric.js
[edit]
[-] isAscii.js
[edit]
[-] isEmpty.js
[edit]
[-] escape.js
[edit]
[-] isEmail.js
[edit]
[-] isLowercase.js
[edit]
[-] isFloat.js
[edit]
[-] isISBN.js
[edit]
[-] isIP.js
[edit]
[-] isFQDN.js
[edit]