Back | Home
الـ Path الحالي: /home/picotech/domains/instantly.picotech.app/public_html/public/uploads/../uploads/../../../../instantly.picotech.app/homes/../../wa.picotech.app/public_html/node_modules/path-exists/../duplexify/./.././node-wav/.././hasown/../validator/../validator/lib
الملفات الموجودة في هذا الـ Path:
.
..
alpha.js
blacklist.js
contains.js
equals.js
escape.js
isAfter.js
isAlpha.js
isAlphanumeric.js
isAscii.js
isBIC.js
isBase32.js
isBase58.js
isBase64.js
isBefore.js
isBoolean.js
isBtcAddress.js
isByteLength.js
isCreditCard.js
isCurrency.js
isDataURI.js
isDate.js
isDecimal.js
isDivisibleBy.js
isEAN.js
isEmail.js
isEmpty.js
isEthereumAddress.js
isFQDN.js
isFloat.js
isFullWidth.js
isHSL.js
isHalfWidth.js
isHash.js
isHexColor.js
isHexadecimal.js
isIBAN.js
isIMEI.js
isIP.js
isIPRange.js
isISBN.js
isISIN.js
isISO31661Alpha2.js
isISO31661Alpha3.js
isISO4217.js
isISO6346.js
isISO6391.js
isISO8601.js
isISRC.js
isISSN.js
isIdentityCard.js
isIn.js
isInt.js
isJSON.js
isJWT.js
isLatLong.js
isLength.js
isLicensePlate.js
isLocale.js
isLowercase.js
isLuhnNumber.js
isLuhnValid.js
isMACAddress.js
isMD5.js
isMagnetURI.js
isMailtoURI.js
isMimeType.js
isMobilePhone.js
isMongoId.js
isMultibyte.js
isNumeric.js
isOctal.js
isPassportNumber.js
isPort.js
isPostalCode.js
isRFC3339.js
isRgbColor.js
isSemVer.js
isSlug.js
isStrongPassword.js
isSurrogatePair.js
isTaxID.js
isTime.js
isURL.js
isUUID.js
isUppercase.js
isVAT.js
isVariableWidth.js
isWhitelisted.js
ltrim.js
matches.js
normalizeEmail.js
rtrim.js
stripLow.js
toBoolean.js
toDate.js
toFloat.js
toInt.js
trim.js
unescape.js
util
whitelist.js

مشاهدة ملف: isCurrency.js

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = isCurrency;

var _merge = _interopRequireDefault(require("./util/merge"));

var _assertString = _interopRequireDefault(require("./util/assertString"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function currencyRegex(options) {
  var decimal_digits = "\\d{".concat(options.digits_after_decimal[0], "}");
  options.digits_after_decimal.forEach(function (digit, index) {
    if (index !== 0) decimal_digits = "".concat(decimal_digits, "|\\d{").concat(digit, "}");
  });
  var symbol = "(".concat(options.symbol.replace(/\W/, function (m) {
    return "\\".concat(m);
  }), ")").concat(options.require_symbol ? '' : '?'),
      negative = '-?',
      whole_dollar_amount_without_sep = '[1-9]\\d*',
      whole_dollar_amount_with_sep = "[1-9]\\d{0,2}(\\".concat(options.thousands_separator, "\\d{3})*"),
      valid_whole_dollar_amounts = ['0', whole_dollar_amount_without_sep, whole_dollar_amount_with_sep],
      whole_dollar_amount = "(".concat(valid_whole_dollar_amounts.join('|'), ")?"),
      decimal_amount = "(\\".concat(options.decimal_separator, "(").concat(decimal_digits, "))").concat(options.require_decimal ? '' : '?');
  var pattern = whole_dollar_amount + (options.allow_decimal || options.require_decimal ? 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 = "( (?!\\-))?".concat(pattern);
  } else if (options.allow_space_after_symbol) {
    pattern = " ?".concat(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 = "(\\(".concat(pattern, "\\)|").concat(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)".concat(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_decimal: true,
  require_decimal: false,
  digits_after_decimal: [2],
  allow_space_after_digits: false
};

function isCurrency(str, options) {
  (0, _assertString.default)(str);
  options = (0, _merge.default)(options, default_currency_options);
  return currencyRegex(options).test(str);
}

module.exports = exports.default;
module.exports.default = exports.default;