All files / app/payment/creditCard unformatCreditCardNumber.ts

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 1255x   55x 28x   28x 1x     27x    
import { number } from 'card-validator';
 
export default function unformatCreditCardNumber(value: string, separator: string = ' '): string {
    const { card } = number(value);
 
    if (!card) {
        return value;
    }
 
    return value.replace(new RegExp(separator, 'g'), '');
}