inferred-types 0.55.5 → 0.55.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7858,6 +7858,23 @@ type IterateOver<TContent extends readonly unknown[], TTrailing extends string>
7858
7858
  */
7859
7859
  type EnsureTrailing<TContent extends string | number | readonly (string | number)[], TTrailing extends string | number> = IsWideType<TContent> extends true ? IsWideType<TTrailing> extends true ? TContent : `${string}${TTrailing}` : IsWideType<TTrailing> extends true ? IsString<TContent> extends true ? `${AsString<TContent>}${string}` : never : TContent extends number ? AsNumber<P<`${TContent}`, `${TTrailing}`>> : TContent extends string ? P<TContent, `${TTrailing}`> : TContent extends readonly unknown[] ? IterateOver<TContent, `${TTrailing}`> : never;
7860
7860
 
7861
+ /** the shae for an American Express long number */
7862
+ type AmericanExpress = `${"34" | "37"}${number} ${number} ${number}`;
7863
+ /** the shape of Visa long numbers */
7864
+ type Visa = `4${number} ${number} ${number} ${number}`;
7865
+ type Mastercard = `${"51" | "55"}${number} ${number} ${number} ${number}` | `2${"2" | "3" | "4" | "5" | "6" | "7"}${number} ${number} ${number} ${number}`;
7866
+ /** the shape for a VISA/Mastercard long number */
7867
+ type VisaMastercard = Visa | Mastercard;
7868
+ /**
7869
+ * Represents the string literal type for either a Mastercard/VISA
7870
+ * format or an American Express card.
7871
+ *
7872
+ * **Related:**
7873
+ * - `IsVisaMastercard`, `IsAmericanExpress`, `IsCreditCard`
7874
+ * - `isVisaMastercard()`, `isAmericanExpress()`, `isCreditCard()`
7875
+ */
7876
+ type CreditCard = VisaMastercard | AmericanExpress;
7877
+
7861
7878
  type UsStateLookup = Mutable<typeof US_STATE_LOOKUP>;
7862
7879
  type UsProvinceLookup = Mutable<typeof US_STATE_LOOKUP_PROVINCES>;
7863
7880
  type _UsStateAbbrev = {
@@ -14027,6 +14044,25 @@ declare function isTomorrow(test: unknown): boolean;
14027
14044
  */
14028
14045
  declare function isYesterday(test: unknown): boolean;
14029
14046
 
14047
+ declare function isVisa(val: unknown): val is Visa;
14048
+ declare function isMastercard(val: unknown): val is Mastercard;
14049
+ declare function isVisaMastercard(val: unknown): val is VisaMastercard;
14050
+ declare function isAmericanExpress(val: unknown): val is AmericanExpress;
14051
+ declare function isCreditCard(val: unknown): val is CreditCard;
14052
+ /**
14053
+ * Given a card's long number, attempt to match this to a card type from:
14054
+ *
14055
+ * - Visa, Mastercard
14056
+ * - American Express
14057
+ * - Discover
14058
+ * - JCB
14059
+ * - Diners Club
14060
+ * - China UnionPay
14061
+ * - Maestro
14062
+ * - Solo
14063
+ */
14064
+ declare function cardType(cardNumber: string | number): string;
14065
+
14030
14066
  /**
14031
14067
  * Type guard which checks whether `val` is a 2 character country
14032
14068
  * representation found in the ISO3166-1 standard.
@@ -15457,4 +15493,4 @@ declare function isVueRef(val: unknown): val is VueRef;
15457
15493
  */
15458
15494
  declare function asVueRef<T extends Narrowable>(value: T): VueRef<T>;
15459
15495
 
15460
- export { type AsClassSelector, type AsList, type BoxValue, type BoxedFnParams, type ConfigRestApi, type CssKeyframeCallback, type CssSelectorOptions, type CsvFormat, type DictionaryWithValueFilter, type DictionaryWithoutValueFilter, type DoesExtendTypeguard, type EndingWithTypeGuard, type EndpointGenerator, type EqualTo, type Finder, type FnParam, type FnParams, type GenParam, type GenParams, type GetEachOptions, type GetInference, type GetInferenceProps, type GetOptions, type Joiner, type KeyframeApi, type Mapper, type Rtn, ShapeApiImplementation, type SingletonClosure, type StartingWithTypeGuard, type StripSurroundConfigured, type SurroundWith, type ToKeyValueSort, type TokenContainerClosure, type TokenFunctionClosure, type TokenSetClosure, type TypeOfTypeGuard, type Unbox, type UndefinedArrayIsUnknown, type UnionClosure, type UrlMeta, type YouTubeMeta, addFnToProps, addPropsToFn, and, asApi, asArray, asChars, asDate, asEscapeFunction, asIsoDate, asOptionalParamFunction, asPhoneFormat, asRecord, asString, asStringLiteral, asType, asTypeToken, asVueRef, box, boxDictionaryValues, capitalize, choices, createConverter, createCssKeyframe, createCssSelector, createErrorCondition, createFifoQueue, createFixedLengthArray, createFnWithProps, createFnWithPropsExplicit, createLifoQueue, createMapper, createObjectMap, createTypeToken, cssColor, csv, defineCss, defineObj, defineObject, defineObjectApi, defineTuple, doesExtend, endsWith, ensureLeading, ensureSurround, ensureTrailing, entries, errCondition, filter, find, fnMeta, fromDefineObject, fromKeyValue, get, getDaysBetween, getEach, getPhoneCountryCode, getTailwindModifiers, getToday, getTokenKind, getTomorrow, getTypeSubtype, getUrlBase, getUrlDefaultPort, getUrlDynamics, getUrlPath, getUrlPort, getUrlProtocol, getUrlQueryParams, getUrlSource, getWeekNumber, getYesterday, getYouTubePageType, handleDoneFn, hasCountryCode, hasDefaultValue, hasIndexOf, hasKeys, hasOverlappingKeys, hasProtocol, hasProtocolPrefix, hasUrlPort, hasUrlQueryParameter, hasWhiteSpace, idLiteral, idTypeGuard, identity, ifArray, ifArrayPartial, ifBoolean, ifChar, ifContainer, ifDefined, ifFalse, ifFunction, ifHasKey, ifLength, ifLowercaseChar, ifNotNull, ifNull, ifNumber, ifObject, ifSameType, ifScalar, ifString, ifTrue, ifUndefined, ifUppercaseChar, indexOf, infer, intersect, intersection, ip6GroupExpansion, ip6Prefix, isAccelerationMetric, isAccelerationUom, isAlpha, isAmazonUrl, isApi, isApiSurface, isAppleUrl, isAreaMetric, isAreaUom, isArray, isArrayToken, isAtomicKind, isAtomicToken, isAustralianNewsUrl, isBelgiumNewsUrl, isBestBuyUrl, isBitbucketUrl, isBoolean, isBooleanLike, isBox, isCanadianNewsUrl, isChineseNewsUrl, isCodeCommitUrl, isConstant, isContainer, isContainerToken, isCostCoUrl, isCountryAbbrev, isCountryCode2, isCountryCode3, isCountryName, isCssAspectRatio, isCsv, isCurrentMetric, isCurrentUom, isCvsUrl, isDanishNewsUrl, isDate, isDefineObject, isDefined, isDellUrl, isDistanceMetric, isDistanceUom, isDomainName, isDoneFn, isDutchNewsUrl, isEbayUrl, isEmail, isEmpty, isEnergyMetric, isEnergyUom, isEqual, isErrorCondition, isEscapeFunction, isEtsyUrl, isFalse, isFalsy, isFnBasedKind, isFnBasedToken, isFnWithParams, isFrenchNewsUrl, isFrequencyMetric, isFrequencyUom, isFunction, isGermanNewsUrl, isGithubIssueUrl, isGithubIssuesListUrl, isGithubOrgUrl, isGithubProjectUrl, isGithubProjectsListUrl, isGithubReleaseTagUrl, isGithubReleasesListUrl, isGithubRepoReleaseTagUrl, isGithubRepoReleasesUrl, isGithubRepoUrl, isGithubUrl, isHexadecimal, isHmUrl, isHomeDepotUrl, isHtmlElement, isIkeaUrl, isIndexable, isIndianNewsUrl, isInlineSvg, isIp4Address, isIp6Address, isIpAddress, isIso3166Alpha2, isIso3166Alpha3, isIso3166CountryCode, isIso3166CountryName, isIsoDate, isIsoDateTime, isIsoExplicitDate, isIsoExplicitTime, isIsoImplicitDate, isIsoImplicitTime, isIsoTime, isIsoYear, isItalianNewsUrl, isJapaneseNewsUrl, isKrogersUrl, isLeapYear, isLength, isLikeRegExp, isLowesUrl, isLuminosityMetric, isLuminosityUom, isLuxonDateTime, isMacysUrl, isMap, isMapToken, isMassMetric, isMassUom, isMetric, isMexicanNewsUrl, isMoment, isNarrowableObject, isNever, isNewsUrl, isNikeUrl, isNorwegianNewsUrl, isNotNull, isNothing, isNull, isNumber, isNumberLike, isNumericArray, isNumericString, isObject, isObjectToken, isOptionalParamFunction, isPhoneNumber, isPowerMetric, isPowerUom, isPressureMetric, isPressureUom, isProtocol, isProtocolPrefix, isReadonlyArray, isRecordToken, isRef, isRegExp, isRepoSource, isRepoUrl, isResistance, isResistanceUom, isRetailUrl, isSameTypeOf, isScalar, isSemanticVersion, isSet, isSetBasedKind, isSetBasedToken, isSetContainer, isSetToken, isShape, isShapeCallback, isSimpleContainerToken, isSimpleContainerTokenTuple, isSimpleScalarToken, isSimpleScalarTokenTuple, isSimpleToken, isSimpleTokenTuple, isSingletonKind, isSingletonToken, isSocialMediaProfileUrl, isSocialMediaUrl, isSouthKoreanNewsUrl, isSpanishNewsUrl, isSpecificConstant, isSpeedMetric, isSpeedUom, isString, isStringArray, isSwissNewsUrl, isSymbol, isTailwindColor, isTailwindColorClass, isTailwindColorName, isTailwindColorTarget, isTailwindColorWithLuminosity, isTailwindColorWithLuminosityAndOpacity, isTailwindModifier, isTargetUrl, isTemperatureMetric, isTemperatureUom, isThenable, isThisMonth, isThisWeek, isThisYear, isTimeMetric, isTimeUom, isToday, isTomorrow, isTrimable, isTrue, isTruthy, isTuple, isTupleToken, isTurkishNewsUrl, isTypeOf, isTypeSubtype, isTypeToken, isTypeTokenKind, isTypeTuple, isUkNewsUrl, isUndefined, isUnset, isUom, isUri, isUrl, isUrlPath, isUrlSource, isUsNewsUrl, isUsPhoneNumber, isUsStateAbbreviation, isUsStateName, isVariable, isVoltageMetric, isVoltageUom, isVolumeMetric, isVolumeUom, isVueRef, isWalgreensUrl, isWalmartUrl, isWayfairUrl, isWholeFoodsUrl, isYesterday, isYouTubeCreatorUrl, isYouTubeFeedHistoryUrl, isYouTubeFeedUrl, isYouTubePlaylistUrl, isYouTubePlaylistsUrl, isYouTubeShareUrl, isYouTubeSubscriptionsUrl, isYouTubeTrendingUrl, isYouTubeUrl, isYouTubeVideoUrl, isYouTubeVideosInPlaylist, isZaraUrl, isZipCode, isZipCode5, isZipPlus4, joinWith, jsonValue, jsonValues, keysOf, kindLiteral, last, list, literal, logicalReturns, lookupCountryAlpha2, lookupCountryAlpha3, lookupCountryCode, lookupCountryName, lowercase, maybePhoneNumber, mergeObjects, mergeScalars, mergeTuples, nameLiteral, narrow, narrowObjectTo, narrowObjectToType, never, objectToApi, objectValues, omit, optional, optionalOrNull, or, orNull, pathJoin, pluralize, removePhoneCountryCode, removeTailwindModifiers, removeUrlProtocol, result, retain, retainAfter, retainAfterInclusive, retainChars, retainUntil, retainUntilInclusive, retainWhile, reverse, rightWhitespace, shape, sharedKeys, shift, simpleContainerToken, simpleContainerTokenToTypeToken, simpleContainerType, simpleScalarToken, simpleScalarTokenToTypeToken, simpleScalarType, simpleToken, simpleType, simpleUnionTokenToTypeToken, slice, split, startsWith, stripAfter, stripBefore, stripChars, stripLeading, stripParenthesis, stripSurround, stripTrailing, stripUntil, stripWhile, surround, takeNumericCharacters, takeProp, toCamelCase, toKebabCase, toKeyValue, toNumber, toNumericArray, toPascalCase, toSnakeCase, toString, toUppercase, trim, trimEnd, trimLeft, trimRight, trimStart, truncate, tuple, twColor, unbox, uncapitalize, union, unionize, unique, uniqueKeys, unset, uppercase, urlMeta, valuesOf, widen, withDefaults, withKeys, withValue, withoutKeys, withoutValue, wrapFn, youtubeEmbed, youtubeMeta };
15496
+ export { type AsClassSelector, type AsList, type BoxValue, type BoxedFnParams, type ConfigRestApi, type CssKeyframeCallback, type CssSelectorOptions, type CsvFormat, type DictionaryWithValueFilter, type DictionaryWithoutValueFilter, type DoesExtendTypeguard, type EndingWithTypeGuard, type EndpointGenerator, type EqualTo, type Finder, type FnParam, type FnParams, type GenParam, type GenParams, type GetEachOptions, type GetInference, type GetInferenceProps, type GetOptions, type Joiner, type KeyframeApi, type Mapper, type Rtn, ShapeApiImplementation, type SingletonClosure, type StartingWithTypeGuard, type StripSurroundConfigured, type SurroundWith, type ToKeyValueSort, type TokenContainerClosure, type TokenFunctionClosure, type TokenSetClosure, type TypeOfTypeGuard, type Unbox, type UndefinedArrayIsUnknown, type UnionClosure, type UrlMeta, type YouTubeMeta, addFnToProps, addPropsToFn, and, asApi, asArray, asChars, asDate, asEscapeFunction, asIsoDate, asOptionalParamFunction, asPhoneFormat, asRecord, asString, asStringLiteral, asType, asTypeToken, asVueRef, box, boxDictionaryValues, capitalize, cardType, choices, createConverter, createCssKeyframe, createCssSelector, createErrorCondition, createFifoQueue, createFixedLengthArray, createFnWithProps, createFnWithPropsExplicit, createLifoQueue, createMapper, createObjectMap, createTypeToken, cssColor, csv, defineCss, defineObj, defineObject, defineObjectApi, defineTuple, doesExtend, endsWith, ensureLeading, ensureSurround, ensureTrailing, entries, errCondition, filter, find, fnMeta, fromDefineObject, fromKeyValue, get, getDaysBetween, getEach, getPhoneCountryCode, getTailwindModifiers, getToday, getTokenKind, getTomorrow, getTypeSubtype, getUrlBase, getUrlDefaultPort, getUrlDynamics, getUrlPath, getUrlPort, getUrlProtocol, getUrlQueryParams, getUrlSource, getWeekNumber, getYesterday, getYouTubePageType, handleDoneFn, hasCountryCode, hasDefaultValue, hasIndexOf, hasKeys, hasOverlappingKeys, hasProtocol, hasProtocolPrefix, hasUrlPort, hasUrlQueryParameter, hasWhiteSpace, idLiteral, idTypeGuard, identity, ifArray, ifArrayPartial, ifBoolean, ifChar, ifContainer, ifDefined, ifFalse, ifFunction, ifHasKey, ifLength, ifLowercaseChar, ifNotNull, ifNull, ifNumber, ifObject, ifSameType, ifScalar, ifString, ifTrue, ifUndefined, ifUppercaseChar, indexOf, infer, intersect, intersection, ip6GroupExpansion, ip6Prefix, isAccelerationMetric, isAccelerationUom, isAlpha, isAmazonUrl, isAmericanExpress, isApi, isApiSurface, isAppleUrl, isAreaMetric, isAreaUom, isArray, isArrayToken, isAtomicKind, isAtomicToken, isAustralianNewsUrl, isBelgiumNewsUrl, isBestBuyUrl, isBitbucketUrl, isBoolean, isBooleanLike, isBox, isCanadianNewsUrl, isChineseNewsUrl, isCodeCommitUrl, isConstant, isContainer, isContainerToken, isCostCoUrl, isCountryAbbrev, isCountryCode2, isCountryCode3, isCountryName, isCreditCard, isCssAspectRatio, isCsv, isCurrentMetric, isCurrentUom, isCvsUrl, isDanishNewsUrl, isDate, isDefineObject, isDefined, isDellUrl, isDistanceMetric, isDistanceUom, isDomainName, isDoneFn, isDutchNewsUrl, isEbayUrl, isEmail, isEmpty, isEnergyMetric, isEnergyUom, isEqual, isErrorCondition, isEscapeFunction, isEtsyUrl, isFalse, isFalsy, isFnBasedKind, isFnBasedToken, isFnWithParams, isFrenchNewsUrl, isFrequencyMetric, isFrequencyUom, isFunction, isGermanNewsUrl, isGithubIssueUrl, isGithubIssuesListUrl, isGithubOrgUrl, isGithubProjectUrl, isGithubProjectsListUrl, isGithubReleaseTagUrl, isGithubReleasesListUrl, isGithubRepoReleaseTagUrl, isGithubRepoReleasesUrl, isGithubRepoUrl, isGithubUrl, isHexadecimal, isHmUrl, isHomeDepotUrl, isHtmlElement, isIkeaUrl, isIndexable, isIndianNewsUrl, isInlineSvg, isIp4Address, isIp6Address, isIpAddress, isIso3166Alpha2, isIso3166Alpha3, isIso3166CountryCode, isIso3166CountryName, isIsoDate, isIsoDateTime, isIsoExplicitDate, isIsoExplicitTime, isIsoImplicitDate, isIsoImplicitTime, isIsoTime, isIsoYear, isItalianNewsUrl, isJapaneseNewsUrl, isKrogersUrl, isLeapYear, isLength, isLikeRegExp, isLowesUrl, isLuminosityMetric, isLuminosityUom, isLuxonDateTime, isMacysUrl, isMap, isMapToken, isMassMetric, isMassUom, isMastercard, isMetric, isMexicanNewsUrl, isMoment, isNarrowableObject, isNever, isNewsUrl, isNikeUrl, isNorwegianNewsUrl, isNotNull, isNothing, isNull, isNumber, isNumberLike, isNumericArray, isNumericString, isObject, isObjectToken, isOptionalParamFunction, isPhoneNumber, isPowerMetric, isPowerUom, isPressureMetric, isPressureUom, isProtocol, isProtocolPrefix, isReadonlyArray, isRecordToken, isRef, isRegExp, isRepoSource, isRepoUrl, isResistance, isResistanceUom, isRetailUrl, isSameTypeOf, isScalar, isSemanticVersion, isSet, isSetBasedKind, isSetBasedToken, isSetContainer, isSetToken, isShape, isShapeCallback, isSimpleContainerToken, isSimpleContainerTokenTuple, isSimpleScalarToken, isSimpleScalarTokenTuple, isSimpleToken, isSimpleTokenTuple, isSingletonKind, isSingletonToken, isSocialMediaProfileUrl, isSocialMediaUrl, isSouthKoreanNewsUrl, isSpanishNewsUrl, isSpecificConstant, isSpeedMetric, isSpeedUom, isString, isStringArray, isSwissNewsUrl, isSymbol, isTailwindColor, isTailwindColorClass, isTailwindColorName, isTailwindColorTarget, isTailwindColorWithLuminosity, isTailwindColorWithLuminosityAndOpacity, isTailwindModifier, isTargetUrl, isTemperatureMetric, isTemperatureUom, isThenable, isThisMonth, isThisWeek, isThisYear, isTimeMetric, isTimeUom, isToday, isTomorrow, isTrimable, isTrue, isTruthy, isTuple, isTupleToken, isTurkishNewsUrl, isTypeOf, isTypeSubtype, isTypeToken, isTypeTokenKind, isTypeTuple, isUkNewsUrl, isUndefined, isUnset, isUom, isUri, isUrl, isUrlPath, isUrlSource, isUsNewsUrl, isUsPhoneNumber, isUsStateAbbreviation, isUsStateName, isVariable, isVisa, isVisaMastercard, isVoltageMetric, isVoltageUom, isVolumeMetric, isVolumeUom, isVueRef, isWalgreensUrl, isWalmartUrl, isWayfairUrl, isWholeFoodsUrl, isYesterday, isYouTubeCreatorUrl, isYouTubeFeedHistoryUrl, isYouTubeFeedUrl, isYouTubePlaylistUrl, isYouTubePlaylistsUrl, isYouTubeShareUrl, isYouTubeSubscriptionsUrl, isYouTubeTrendingUrl, isYouTubeUrl, isYouTubeVideoUrl, isYouTubeVideosInPlaylist, isZaraUrl, isZipCode, isZipCode5, isZipPlus4, joinWith, jsonValue, jsonValues, keysOf, kindLiteral, last, list, literal, logicalReturns, lookupCountryAlpha2, lookupCountryAlpha3, lookupCountryCode, lookupCountryName, lowercase, maybePhoneNumber, mergeObjects, mergeScalars, mergeTuples, nameLiteral, narrow, narrowObjectTo, narrowObjectToType, never, objectToApi, objectValues, omit, optional, optionalOrNull, or, orNull, pathJoin, pluralize, removePhoneCountryCode, removeTailwindModifiers, removeUrlProtocol, result, retain, retainAfter, retainAfterInclusive, retainChars, retainUntil, retainUntilInclusive, retainWhile, reverse, rightWhitespace, shape, sharedKeys, shift, simpleContainerToken, simpleContainerTokenToTypeToken, simpleContainerType, simpleScalarToken, simpleScalarTokenToTypeToken, simpleScalarType, simpleToken, simpleType, simpleUnionTokenToTypeToken, slice, split, startsWith, stripAfter, stripBefore, stripChars, stripLeading, stripParenthesis, stripSurround, stripTrailing, stripUntil, stripWhile, surround, takeNumericCharacters, takeProp, toCamelCase, toKebabCase, toKeyValue, toNumber, toNumericArray, toPascalCase, toSnakeCase, toString, toUppercase, trim, trimEnd, trimLeft, trimRight, trimStart, truncate, tuple, twColor, unbox, uncapitalize, union, unionize, unique, uniqueKeys, unset, uppercase, urlMeta, valuesOf, widen, withDefaults, withKeys, withValue, withoutKeys, withoutValue, wrapFn, youtubeEmbed, youtubeMeta };
@@ -4203,6 +4203,88 @@ function isYesterday(test) {
4203
4203
  return false;
4204
4204
  }
4205
4205
 
4206
+ // src/type-guards/finance/CreditCards.ts
4207
+ function isVisa(val) {
4208
+ if (isString(val) && val.startsWith("4")) {
4209
+ const parts = val.split(" ");
4210
+ return parts.length === 4 && parts.every((i) => isNumberLike(i) && i.length === 4);
4211
+ }
4212
+ return false;
4213
+ }
4214
+ function isMastercard(val) {
4215
+ if (isString(val) && val.startsWith("4")) {
4216
+ const parts = val.split(" ");
4217
+ return parts.length === 4 && parts.every((i) => isNumberLike(i) && i.length === 4) && ["51", "55", "22", "23", "24", "25", "26", "27"].some((i) => val.startsWith(i));
4218
+ }
4219
+ return false;
4220
+ }
4221
+ function isVisaMastercard(val) {
4222
+ return isVisa(val) || isMastercard(val);
4223
+ }
4224
+ function isAmericanExpress(val) {
4225
+ if (isString(val)) {
4226
+ const parts = val.split(" ");
4227
+ return parts.length === 3 && parts.every(
4228
+ (i) => isNumberLike(i) && parts[0].length === 4 && parts[1].length === 6
4229
+ );
4230
+ }
4231
+ return false;
4232
+ }
4233
+ function isCreditCard(val) {
4234
+ return isVisaMastercard(val) || isAmericanExpress(val);
4235
+ }
4236
+ function cardType(cardNumber) {
4237
+ const cleanedNumber = String(cardNumber).replace(/\D/g, "");
4238
+ const length = cleanedNumber.length;
4239
+ if (!isValidLength(length)) {
4240
+ return "invalid";
4241
+ }
4242
+ if (!luhnCheck(cleanedNumber)) {
4243
+ return "invalid";
4244
+ }
4245
+ const cardTypes = [
4246
+ { name: "Visa", lengths: [16], prefixes: [/^4/] },
4247
+ { name: "Mastercard", lengths: [16], prefixes: [/^(51|52|53|54|55|222[1-9]|22[3-9]\d|2[3-6]\d{2}|27[01]\d|2720)/] },
4248
+ { name: "American Express", lengths: [15], prefixes: [/^3[47]/] },
4249
+ { name: "Discover", lengths: [16], prefixes: [/^(6011|622(12[6-9]|1[3-9]\d|2[0-4]\d|25\d|6[4-9]|7[0-4]|8[0-4]|9\d)|64[4-9]|65)/] },
4250
+ { name: "JCB", lengths: [16], prefixes: [/^(35|2131|1800)/] },
4251
+ { name: "Diners Club", lengths: [14, 16], prefixes: [/^(30[0-5]|36|38)/] },
4252
+ { name: "China UnionPay", lengths: [16, 17, 18, 19], prefixes: [/^(62|88)/] },
4253
+ { name: "Maestro", lengths: [12, 13, 14, 15, 16, 17, 18, 19], prefixes: [/^(5018|5020|5038|6304)/] },
4254
+ { name: "Solo", lengths: [16, 18, 19], prefixes: [/^(6334|6767)/] }
4255
+ ];
4256
+ for (const type of cardTypes) {
4257
+ if (type.lengths.includes(length)) {
4258
+ for (const prefix of type.prefixes) {
4259
+ if (prefix.test(cleanedNumber)) {
4260
+ return type.name;
4261
+ }
4262
+ }
4263
+ }
4264
+ }
4265
+ return "invalid";
4266
+ }
4267
+ function isValidLength(length) {
4268
+ const validLengths = [13, 14, 15, 16, 17, 18, 19];
4269
+ return validLengths.includes(length);
4270
+ }
4271
+ function luhnCheck(num) {
4272
+ let sum = 0;
4273
+ let double = false;
4274
+ for (let i = num.length - 1; i >= 0; i--) {
4275
+ let n = Number.parseInt(num.charAt(i), 10);
4276
+ if (double) {
4277
+ n *= 2;
4278
+ if (n > 9) {
4279
+ n -= 9;
4280
+ }
4281
+ }
4282
+ sum += n;
4283
+ double = !double;
4284
+ }
4285
+ return sum % 10 === 0;
4286
+ }
4287
+
4206
4288
  // src/type-guards/isString.ts
4207
4289
  function isString(value) {
4208
4290
  return typeof value === "string";
@@ -5581,6 +5663,7 @@ export {
5581
5663
  box,
5582
5664
  boxDictionaryValues,
5583
5665
  capitalize,
5666
+ cardType,
5584
5667
  choices,
5585
5668
  createConverter,
5586
5669
  createCssKeyframe,
@@ -5678,6 +5761,7 @@ export {
5678
5761
  isAccelerationUom,
5679
5762
  isAlpha,
5680
5763
  isAmazonUrl,
5764
+ isAmericanExpress,
5681
5765
  isApi,
5682
5766
  isApiSurface,
5683
5767
  isAppleUrl,
@@ -5705,6 +5789,7 @@ export {
5705
5789
  isCountryCode2,
5706
5790
  isCountryCode3,
5707
5791
  isCountryName,
5792
+ isCreditCard,
5708
5793
  isCssAspectRatio,
5709
5794
  isCsv,
5710
5795
  isCurrentMetric,
@@ -5788,6 +5873,7 @@ export {
5788
5873
  isMapToken,
5789
5874
  isMassMetric,
5790
5875
  isMassUom,
5876
+ isMastercard,
5791
5877
  isMetric,
5792
5878
  isMexicanNewsUrl,
5793
5879
  isMoment,
@@ -5893,6 +5979,8 @@ export {
5893
5979
  isUsStateAbbreviation,
5894
5980
  isUsStateName,
5895
5981
  isVariable,
5982
+ isVisa,
5983
+ isVisaMastercard,
5896
5984
  isVoltageMetric,
5897
5985
  isVoltageUom,
5898
5986
  isVolumeMetric,