MCPcopy
hub / github.com/faker-js/faker / replaceCreditCardSymbols

Method replaceCreditCardSymbols

src/modules/helpers/index.ts:373–384  ·  view source on GitHub ↗

* Replaces the symbols and patterns in a credit card schema including Luhn checksum. * * This method supports both range patterns `[4-9]` as well as the patterns used by `replaceSymbolWithNumber()`. * `L` will be replaced with the appropriate Luhn checksum. * * @param string The credi

(
    string: string = '6453-####-####-####-###L',
    symbol: string = '#'
  )

Source from the content-addressed store, hash-verified

371 * @since 5.0.0
372 */
373 replaceCreditCardSymbols(
374 string: string = '6453-####-####-####-###L',
375 symbol: string = '#'
376 ): string {
377 // default values required for calling method without arguments
378
379 string = legacyRegexpStringParse(this.faker, string); // replace [4-9] with a random number in range etc...
380 string = legacyReplaceSymbolWithNumber(this.faker, string, symbol); // replace ### with random numbers
381
382 const checkNum = luhnCheckValue(string);
383 return string.replace('L', String(checkNum));
384 }
385
386 /**
387 * Generates a string matching the given regex like expressions.

Callers 3

helpers.spec.tsFile · 0.80
imeiMethod · 0.80
creditCardNumberMethod · 0.80

Calls 3

luhnCheckValueFunction · 0.90
legacyRegexpStringParseFunction · 0.85

Tested by

no test coverage detected