MCPcopy Create free account
hub / github.com/untitleduico/react / formatCardNumber

Function formatCardNumber

components/base/input/input-payment.tsx:68–80  ·  view source on GitHub ↗
(number: string)

Source from the content-addressed store, hash-verified

66 * Format the card number in groups of 4 digits (i.e. 1234 5678 9012 3456).
67 */
68export const formatCardNumber = (number: string) => {
69 // Remove non-numeric characters
70 const cleaned = number.replace(/\D/g, "");
71
72 // Format the card number in groups of 4 digits
73 const match = cleaned.match(/\d{1,4}/g);
74
75 if (match) {
76 return match.join(" ");
77 }
78
79 return cleaned;
80};
81
82interface PaymentInputProps extends InputProps {}
83

Callers 1

PaymentInputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected